Get DevWP - WordPress Development Theme
Local WordPress Development with XAMPP for Windows

Local WordPress Development with XAMPP for Windows

When it comes to local WordPress development on Windows, XAMPP is a popular choice among developers. XAMPP is a comprehensive package that includes Apache, MySQL, PHP, and Perl, providing everything you need to create a local development environment. In this guide, I’ll walk you through the process of setting up XAMPP and configuring it for optimal WordPress development.

Why XAMPP?

There are plenty of options to choose from when it comes to setting up a local developer environment when it comes to developing for WordPress. I’ve personally used most of the main options available and I often switch back and forth to see if there are any significant differences. When it comes to Windows, I find XAMPP to currently being the best option because of it’s simplicity and the ability to configure it to suit your needs.

I try and configure my local development environment to closely match that of my production environment. This isn’t the easiest considering my production server runs on Linux and when developing locally, I use XAMPP on Windows and MAMP on macOS. But I do configure PHP and MySQL to closely match and try to ensure consistency.

This article is part of a series of articles and videos on how to Develop your own Custom WordPress Themes with DevWP.

This is an updated workflow to WordPress theme development which I covered in 2023.
Let’s get started with this guide.

Checkout the video that goes with this quick start guide.

Download XAMPP

First thing you should do is visit the official website to download XAMPP which is Apache Friends and download the installer for Windows and download the latest version and then start the process of installing it and following the on-screen instructions.

Enabling Essential PHP Extensions

To ensure your development environment is fully functional, you’ll need to enable the GD extension in PHP. Follow these steps:

  • Start XAMPP – Open the XAMPP Control Panel.
  • Configure Apache – Click on the “Config” button next to Apache and select PHP.ini.
  • Edit PHP.ini -Search for extension=fileinfo and remove the the semicolon for the following extensions: extension=gd, extension=intl, extension=zip.
  • Restart Apache – Save the changes and restart Apache via the XAMPP Control Panel.

Key File Locations

  • Executable File Location: C:\xampp\php\php.exe
  • PHP.ini File Location: C:\xampp\php\php.ini
  • MySQL Configuration File Location: C:\xampp\mysql\bin\my.ini

Adding PHP and MySQL to Your System Path

Ensuring that PHP and MySQL are in your system’s PATH allows you to use these tools from the command line. Here’s how to set it up on Windows:

  1. Open Environment Variables:
    • Search for ‘Environment Variables’ in the Windows search bar and open it.
  2. Edit Environment Variables:
    • Click on the ‘Environment Variables’ button.
  3. Edit System Path:
    • In the ‘System Variables’ section, find and select the ‘Path’ variable, then click ‘Edit’.
  4. Add PHP Path:
    • Click ‘New’ and add C:\xampp\php.
  5. Add MySQL Path:
    • Click ‘New’ and add C:\xampp\mysql\bin.
  6. Apply Changes:
    • Save the changes and restart your computer.
  7. Verify PHP Installation:
    • Open Command Prompt and type php -v to confirm PHP is in your system path.

Fine-tuning PHP and MySQL Settings

To optimize your WordPress development environment, you can fine-tune the php.ini and my.ini files. Here are some recommended settings:

PHP.ini Adjustments

  1. Open PHP.ini:
    • Locate and open C:\xampp\php\php.ini.
  2. Update Settings:
    
    memory_limit = 2048M
    max_execution_time = 300
    max_input_time = 240
    post_max_size = 64M
    upload_max_filesize = 64M
    mysql.connect_timeout = 240
    
  3. Save and Restart Apache:
    • Save the file and restart Apache via the XAMPP Control Panel.

MySQL (my.ini) Adjustments

  1. Open My.ini:
    • Locate and open C:\xampp\mysql\bin\my.ini.
  2. Update Settings:
    
    [mysqld]
    max_allowed_packet = 512M
    innodb_buffer_pool_size = 2G
    
    [mysqldump]
    max_allowed_packet = 512M
    
  3. Save and Restart MySQL:
    • Save the file and restart MySQL via the XAMPP Control Panel.

Document Root and Local URL

  • Local URL:http://localhost
  • Document Root: C:\xampp\htdocs

This is where you will place your various WordPress installations. For example:

  • C:\xampp\htdocs\wordpress
  • C:\xampp\htdocs\dev

Troubleshooting

If you encounter any issues while setting up or using XAMPP, here are a few common solutions:

  • Make sure you have the latest version of XAMPP installed.
  • Ensure that no other web servers or services are conflicting with XAMPP’s ports (e.g., Apache uses port 80 and MySQL uses port 3306).
  • Check the XAMPP error logs located in C:\xampp\apache\logs and C:\xampp\mysql\data for any specific error messages.
  • Verify that your firewall or antivirus software is not blocking XAMPP.

If you’re still facing problems, consult the XAMPP documentation or seek support from the XAMPP community forums.

Conclusion

By following these steps, you’ll have a fully functional local development environment with XAMPP, optimized for WordPress theme development. This setup ensures that you can develop, test, and debug your themes efficiently before deploying them to a live server.



View Our Themes