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!
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 XAMPP
Go to the Apache Friends website and download XAMPP.
This tutorial does not discuss the installation of XAMPP. For more information about XAMPP, go to the official XAMPP (http://www.apachefriends.org/en/xampp.html) web site.
Setting Up Your MySQL Database
Before we install WordPress, we need a database.
On your XAMPP Control Panel, click the “Admin” button in the MySQL section.
Click “Admin” to set up MySQL.
A new browser window will automatically open with the phpMyAdmin interface.
Click “Admin” to set up MySQL or go to “localhost/phpmyadmin” in your browser.
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.
Quickly and easily set up a new MySQL database for WordPress.
Download and Install WordPress
Download 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.
Go to XAMPP/htdocs folder on your computer and unzip WordPress there.
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.
My installation of WordPress is called “WP.”
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:
Update your wp-config.php file with your database details.
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.
Set up WordPress using the famous five minute install process.
Enter your details and click “Install WordPress.”
Your WordPress installation is now complete!
Setting up WordPress Multisite
Having 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:
Activate Multisite 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.”
Enabling Multisite will add a new “Network Setup” sub-menu item to WordPress.
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:
Edit your wp-config file to get Multisite up and running.
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!
Your Multisite network should now be up and running!
Summing Up
XAMPP 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.