How to Install WordPress Locally for PC/Windows with XAMPP

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.

XAMPP
Easily install XAMPP for Windows and run your own local server environment for WordPress.

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.

Apache Friends Site
Download XAMPP from the Apache Friends website.

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.

XAMPP installer
XAMPP setup wizard.

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.

XAMPP options
Choose the components of the software you want to install and untick the ones you don’t want.

Next, select the folder where you would like to install XAMPP. I’m going to create a new folder in C:Program FilesXAMPP.

XAMPP select folder
Select the folder where you would like to install 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.”

XAMPP Bitnami
In this tutorial we’re going to set up WordPress manually, so untick this option.

After going through all those options, XAMPP is now ready to install.

XAMPP ready to install
Almost there…

Once installed, you’ll be asked whether you would like to start the Control Panel. Leave this option ticked and click “Finish.”

XAMPP Control Panel
Installation is quick and painless.

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.

XAMPP firewall and security
Allow access for Apache and MySQL to ensure XAMPP can run.

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”.

XAMPP Control Panel
The 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.

XAMPP running smoothly...
XAMPP running smoothly.

You can check if your new local server is installed by visiting http://localhost in your browser.

XAMPP localhost
Localhost is now installed and working!

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.

MySQL admin
Click “Admin” to set up MySQL.

A new browser window will automatically open with the phpMyAdmin interface.

XAMPP phpMyAdmin
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.

XAMPP MySQL database
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.

XAMPP folder
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.

Install WordPress
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:

wp-config database details
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.

Famous five minute install
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
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.”

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:

Multsite wp-config
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 .htaccess

Edit your .htaccess file to complete your Multisite installation.

Multisite should now be enabled and working on your WordPress site!

Multisite network
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.

Next week I’ll look at how to set up WAMP, another popular option for setting up a local server environment for Windows.

Do you use XAMPP? Tell us in the comments below.

Comments (30)

  1. Great tutorial!

    Have you considered making a video showing how to set up MAMP PRO to work as a server so developers can show their “work-process” to clients without needing to upload the database and files to another server?

    Sincerely,
    Mika

  2. Thanks for this info on setting up WordPress. I have followed each step but obviously have a problem.

    When I get to:

    Now we can get on with installing WordPress.

    Open your browser and go to http://localhost/wp/

    I get an error message saying: Error establishing a database connection

    I have checked the name of my database, the .php file edits, just can’t seem to see where I have gone wrong. Any help would be greatly appreciated.

    • It looks like MySQL isn’t working properly. Are the database details in your wp-config.php file correct? Is the database name the same as the name you of the database you created in phpMyAdmin? Is the username root? And did you leave the password blank?

  3. Database is named wp
    Folder in htdocs is named wp

    // ** MySQL settings – You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘wp’);

    /** MySQL database username */
    define(‘DB_USER’, ‘ROOT’);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘ ‘);

    /** MySQL hostname */
    define(‘DB_HOST’, ‘localhost’);

    everything seems to be right, but obviously isn’t

  4. Yes they were, but I just stopped them and started them again but got the same error message

    11:22:50 AM [Apache] Attempting to stop Apache (PID: 1576)
    11:22:50 AM [Apache] Attempting to stop Apache (PID: 5976)
    11:22:50 AM [Apache] Status change detected: stopped
    11:22:51 AM [mysql] Attempting to stop MySQL (PID: 7088)
    11:22:51 AM [mysql] Status change detected: stopped
    11:22:52 AM [Apache] Attempting to start Apache app…
    11:22:53 AM [Apache] Status change detected: running
    11:22:54 AM [mysql] Attempting to start MySQL app…
    11:22:54 AM [mysql] Status change detected: running

  5. Can I please tell you that the info in that post fixed my problem. I edited the “users” as per that post and I now have the WordPress installation screen.

    Hopefully I can follow the rest of your instructions above with no more problems. Thanks for your help

  6. Through the rest with all things looking like they work OK.

    Now the new task of learning how to create sites and import themes into WordPress. Do you have any recommendations? I have created sites using HTML/CSS but am totally new to WordPress.

    Thanks again

  7. Just to get started, I probably wanted to be able to import a theme (probably just a free one to practice) and then be able to customize. Need to practice finding my way around WordPress.

  8. Nice info explained in a well detailed way. I just installed Xampp and thinking that I had wp installed on Local host. After reading this I setup my test sites on Local host and started running them. Thanks a lot for the article.

  9. Thanks for the well explained, This improve my knowledge to install WP at localhost.

    But why it showing ftp credentials errors at uploading any theme or plugin?

  10. Thank you for explaining how to install wordpress and xampp locally!

    I have successfully installed xampp following your steps. I then downloaded the wordpress zip and extracted it in hotdocs folder under xampp, as you suggested. I also renamed the wp-config-sample.php to wp-config.ph and then opened the file and edited the information for username, database, password. Then save. However, when I try to access http://localhost/nameofmydatabase the page doesn’t connect, the browser says url not found, error 404. I have even repeated the process of creating a new database first with xampp and then extracting wordpress again and editing the wp-config.php but I get the same error when trying to access the url.

    I don’t know if I have missed a step or if there’s another problem. Do you know how I can access the url to run wordpress?
    Thanks in advance!

  11. Thanks for a great tutorial. Worked almost perfectly.

    I copied what was in your .htaccess and made the alterations to wp-config.php but they didn’t work. I found If you follow the wordpress instructions when clicking ‘Tools->Network Setup’ it works fine.

    Any recommendations on how we can sync the local wordpress site with a online website?

  12. I need some help with the setting up.
    The installation is successful, but when I enter “http://localhost” I get error.
    I using WIn7 and I have IIS installed

    The error is:
    IIS 7.5 Detailed Error – 500.52 – URL Rewrite Module Error.
    Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded (“gzip”).

    How I can fix this?

  13. Hello,

    I cannot seem to figure out why I am getting this error when I connect to localhost

    Object Not Found.

    I have followed the instructions here.

    Also, for some reason I am not able to download xampp or wordpress to program files and I am forced to download to the C:\ I get a warning that the folder is full or something like that, could that be making a difference?

  14. Hi, I am having trouble adding multiple sites to the page… I manage to add them but get the following:

    “Access forbidden!

    You don’t have permission to access the requested directory. There is either no index document or the directory is read-protected.

    If you think this is a server error, please contact the webmaster.

    Error 403

    localhost
    Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.5.15″

    I can access the original site but not any that I add… strangely even though they appear added when I click ‘add site’ I also get a message saying “There is no disk in the drive. Please insert a disk into drive \device\harddisk2\DR2″ I hit cancel/continue a few times and it goes away but does add the site to the list but doesn’t work anyway.

Participate