Setting up a local sever environment on your computer will save you a bunch of time if you regularly test or develop themes and plugins.Not only will your local sites run much quicker than they would online, but you’ll also have a much safer testing environment away from a live site.
Having a localhost environment has dramatically improved my workflow and is even an important part of my WordPress working life. It’s such a waste of money using an online WordPress installation with a web host as a test environment!
This week we’ve looked at Mac solutions for local machines. Today we’re going to look at XAMPP for Windows, a free, popular and easy to install server environment application that’s open source.
What is XAMPP?XAMPP stand for cross-platform, Apache, MySQL, PHP and Perl. It’s a simple and lightweight solution that allows you to create a local web server for testing purposes.
Since XAMPP is cross-platform, it also works on Mac and LInux, but today we’re going to look at setting up XAMPP on Windows 7.
WordPress isn’t a stand-alone application and needs server software to run. XAMPP provides the necessary environment needed to run WordPress on a local machine.
Installing XAMPPGo to the Apache Friends website and download XAMPP.
The XAMPP file is 125MB. Once downloaded, launch the installer.
You may receive warnings about installing the software on your computer. As you would when installing any software on Windows, use your best judgment.
The XAMPP setup wizard will guide you through the installation.
In the next window you will be asked to select which components of the software you would like to install and which one you don’t want. Some options, such as Apache and PHP are greyed out because they are essential to running the software.
It’s up to you which components you want and don’t want. Since I we want to run WordPress on this localhost, I’ll leave MySQL and phpMyAdmin checked and uncheck the remaining options.
Next, select the folder where you would like to install XAMPP. I’m going to create a new folder in C:\Program Files\XAMPP.
In the next window you’ll be asked whether you would like to install Bitnami for XAMPP, which offers free tools for installing WordPress, Drupal and Joomla! on top of XAMPP. We’re going to install WordPress manually and without this promotional program, so untick “Learn more about Bitnami for XAMPP” and click “Next.”
After going through all those options, XAMPP is now ready to install.
Once installed, you’ll be asked whether you would like to start the Control Panel. Leave this option ticked and click “Finish.”
If you receive any security/firewall warnings during the installation process (such as the one below), make sure you check “Private networks, such as my home or work network” and click “Allow access.” This is very important. If you don’t allow access, XAMPP won’t work.
If you left “Do you want to start the Control Panel now?” checked during installation, the Control Panel will automatically open. If not, go to the XAMPP folder on you computer and open “XAMPP Control Panel”.
Start up both Apache and MySQL. If you have installed XAMPP properly, both components should run fine without any errors, however, if there are any other applications on your computer using the same ports as these modules then you need to quit the conflicting applications using the same ports and restart XAMPP.
You can check if your new local server is installed by visiting http://localhost in your browser.
Setting Up Your MySQL DatabaseBefore we install WordPress, we need a database.
On your XAMPP Control Panel, click the “Admin” button in the MySQL section.
A new browser window will automatically open with the phpMyAdmin interface.
Click on “Databases” near the top-left and you’ll be prompted to create a new database. I’ve called mine “WP”. When you’ve entered a name, click “Create” and close the window.
Sign up for more
Download and Install WordPressDownload the latest version of WordPress.
In order to get WordPress working with XAMPP we need to unzip WordPress to the right folder. Go to the XAMPP folder on your computer and open the htdocs folder, i.e. C:/Program Files/XAMPP/htdocs.
Unzip WordPress into its own folder and rename it whatever you like. For consistency, I’m going to call this installation of WordPress “WP” to match the name of the database I just created.
Open your WordPress folder, find the wp-config-sample.php file and rename it wp-config.php. Open the file and scroll down until you see the following lines:
These lines of code define the login details for your database. Replace “database_name_here” with the name of your database, which in my case is “WP.”
Replace “username_here” with “root” and leave “password_here” blank.
Save the file and close it.
Now we can get on with installing WordPress.
Open your browser and go to http://localhost/wp/
You should see the welcome screen for the famous five minute WordPress installation process.
Enter your details and click “Install WordPress.”
Your WordPress installation is now complete!
Setting up WordPress MultisiteHaving Multisite setup on a local machine provides a great way to test themes and plugins in a Multisite environment, but also makes it a quick and easy to have multiple sites running at once.
Open your wp-config.php file again and add/edit the following lines to activate Multisite’s installation mode:
Open XAMPP and ensure your Apache and MySQL servers are running.
Login to your localhost site in your browser and under “Tools” you will now have a new option, “Network Setup.”
Enter a name for your network and your email address, then click “Install.”
WordPress will prompt you to edit your wp-config.php and .htaccess files.
Following the onscreen instructions, open wp-config.php and add the following lines underneath your previous edit:
Next, open .htaccess. If you can’t find it, make sure hidden files are displaying on your computer.
Your .htaccess file should look like this:
Edit your .htaccess file to complete your Multisite installation.
Multisite should now be enabled and working on your WordPress site!
Summing UpXAMPP provides an easy way to run a local server environment on your Windows machine, allowing you to test and develop locally, rather than installing WordPress online. It will also save you a bunch of time since you won’t have to install and uninstall WordPress each time you test themes and plugins.
The great thing about XAMPP is that it’s free and also open source. You can set up as many installations of WordPress as you want and it’s just as easy to set up Multsite.
Next week I’ll look at how to set up WAMP, another popular option for setting up a local server environment for Windows.