Install WordPress Locally on Windows with Xampp

Today I’ve got a reader-requested tutorial about how you can install WordPress on your Windows 7 computer (same applies for Windows XP & Vista). This is such an important part of my WordPress working life, and if you don’t know how to do it, now’s your chance to learn. But first…..

Why Would I Want to Install WordPress on my Computer?

different local WordPress installation foldersInstalling WordPress locally gives you a fantastic test environment. You can install as many WordPresses as you want on your computer. On mine I’ve got:

  • Single-site
  • Multisite
  • Beta
  • Plugins
  • WordPress

This gives me all sorts of scope for testing stuff out, playing around – a WordPress playground right on my computer.

Let’s get started:

1. Download Xampp

Xampp is an Apache distribution containing MySQL, PHP and Perl. This makes it awesome for WordPress. You can download it from here. 

There are a number of different distributions so make sure you select the distribution that’s correct for your operating system. For the purposes of this tutorial we want the Windows distribution.

Click on the distribution.

Click on the windows distributionClick on the installer.

click on the installer and select save

2. Install Xampp

Double click on the installer and choose your language.

choose your installation language

Decide where you want to install xampp.

choose the location for your installation

Click install.

click install

Sit back, relax, wait for it to install.

it might take a few minutes!

3. Fire up Xampp

Start Xampp. Start Apache and MySQL.

Click on the "Start" buttons beside Apache and MySQL

You may get a warning from Windows. You want to make sure that Windows allows access.

prevent windows firewall from blocking access

You can check to see if your new local server is installed by visiting http://localhost

xampp splash screen

Nice!

4. Set up MySQL Database

On your Xampp control panel click the admin button beside MySQL.

click the MySQL admin button on xampp

In your browser you’ll be taken to the MySQL dashboard. You need to fill in the details for your new database:

Insert the name of your database and choose utf_unicode_8 for collation

  • Set your MySQL connection collation: to utf8_unicode_ci
  • Choose the name for your database. I’m naming this one singlesite – you can call it whatever you want.

Note: if you are doing a live installation on a server you must add a username and password. Do not use “root” ever on a live site. This isn’t necessary on a local installation.

5. Download and unzip WordPress

Download WordPress.

You need to unzip it to the correct folder on your computer. Find the Xampp folder and navigate to xampp>htdocs

location at c > xampp > htdocs

Unzip WordPress there and rename the WordPress folder to whatever name you want. I usually match mine to my database name.

6. Configure WordPress

Open up wp-config-sample.php and find the MySQL settings.

find wp-config-sample in the wordpress folderHere is what you need to update the settings to:

/** The name of the database for WordPress */
 define('DB_NAME', 'singlesite');
/** MySQL database username */
 define('DB_USER', 'root');
/** MySQL database password */
 define('DB_PASSWORD', '');
/** MySQL hostname */
 define('DB_HOST', 'localhost');

Remember to replace singlesite with whatever you called your database.

Save the file in your root WordPress folder as wp-config.php

save your file as wp-config.php

7. Install WordPress

Open up your browser and navigate to http://localhost/singlesite/

The familiar WordPress installation screen will appear.

wordpress five minute install screen

Fill in your details and click “Install WordPress.”

There you go – WordPress is installed locally on your computer.

WordPress installed to localhost

Have fun!

Comments (66)

  1. Why not just use WP as mentioned previously on this blog?

    Are there any advantages to the xampp route instantWP?

    Cause it sure is slick to have it cooking with one click and be able to move the whole WP install around or copy it by just moving or copying one folder.

  2. If you’re doing a comparison you could take a look at Bitnami. I have used this and seems similar to Xampp. InstantWP seems easiest though.

    One aspect worth testing is how each it is to import from your live WP system, dev / test locally and move back.

  3. I’ve used both – XAMPP and Instant WP and IWP is the one I like more. I don’t know for you guys, but on my PC xampp doesn’t work when I am signed in Skype. Need to close Skype in order to use xampp…

  4. Hi Siobhan, your tutorial looks quite straight forward and well presented but i am having problems with step 4. When i click ‘Admin’ next to the mySQL button nothing happens? Ive tried it on windows 7 and XP systems. Ive also asked someone else to test it out on their computer and they are getting the same result. Do you have any idea what the problem could be? Im using Xampp control panel version 2.5 (9. May 2007)

    Also i noticed in your tutorial the Xampp control panel is different in step 4 from the one in step 3. Is there a reason for this?

    Thanks – Dave

  5. As someone who is on the go at nearly all hours of the day, is there a way to manage my wordpress using a mobile version of this? I’ve asked around even called a technical staffing firm, and from what I hear theres only a viewing app from WP but thats it..

  6. Thank you for this article – most helpful. If I want to set up and test multiple WordPress sites, do I follow these steps as written? What would I do next, or instead, to create and connect to the multiple sites? Two are sites that are created that I would like to have also in a local testing environment as we are making updates (it is a free wordpress site), and two are new sites that will be developed and then loaded via hosting (not free versions but hosted WP).

    Thank you!

    ~ Caprice

  7. Siobhan – awesone post and easy to follow. I am having the same issue as Dave 28.aug.2011.
    I have changed the skype port (thanks Stephan) and tried to run Aampp again with no luck. It just keeps running.

    a

  8. Thanks for the tutorial! I am, however, having one trouble spot:

    After several attempts and double checking that I am following the steps correctly, I cannot get past step 6. After saving the wp-config.php file with the proper edits, I try to launch the page at http://localhost/singlesite and get an Error 404 – Not Found.

    I’m not really sure what I’m doing wrong here…any help?

    (I did purposefully name mine “singlesite” as well, for reference.)

  9. Thanks for this wonderful document, for me everything worked fine except last step. But I think, being new to web technology, I’m not keeping my unziped wordpress folder in proper directory. Will you explain where I need to keep my wordpress folder?

    Thanks in advance.

    • Unzip all of the files and folders in the wordpress folder into htdocs/singlesite (i.e. they shouldn’t be in the WordPress folder anymore)

      Or you can unzip the WordPress folder to /htdocs/ in which case your address for your WP site would be localhost/wordpress/

      • I was having the same error message. The way I fixed my problem was by moving the contents of the wordpress folder into one called singlesite (same as above), after that it didn’t recognize the database I had previously created. I dropped the database, and then created another one (named the same thing)and voila!! worked like a charm.

  10. Nicely done, except that your instructions are unclear at a couple of points.

    Under #4, you leave out a couple of steps/screens that appear at least on my Win7, XAMPP/PHPadmin installation: I need to select MySql. Several databases appear already to have been created, included on called “test.” When I get to “create database,” there is no connection option. I get a log-in screen with the user field blank. I used “root,” but it’s not clear to me whether I could have named any user.

    Under #5, you instruct us to “navigate to htdocs,” and advise us to download/unzip WordPress… but you don’t specify where. In the htdocs directory, in a new directory under the desired name of the installation… if you do that, WordPress will download into yet another subdirectory…

    The correct choices for the above will no doubt appear obvious to an experienced user, but will create uncertainty and confusion for a first-timer. The choices would easily and simply be clarified with just a couple of small additions, for instance by showing full paths in the example images.

  11. Hey great Tutorial. I noticed you had a multisite directory in your htdocs, I’m going to guess for this site you enabled the wordpress multisite feature. I’ve actually been trying to do this for some time and I’ve been running into a few problems. It would be great if you could point me in the right direction as to how I would go about doing this properly. I’m OK on enabling the multisite options, most of my problems lie in the configuration of the server and the hosts file.

  12. Also had the same issue in Step 7, with http://localhost/singlesite error!
    Went back to step 6 and inserted my MySql Database password in the MySql Settings section in wp-config.php

    eg…

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

    Then accessed WP Setup via url:
    http://localhost/wordpress/wp-admin/install.php

    So far, so good, although I am currently downloading Instant WordPress too as I like the idea of being able to run WordPress off a Flash Drive (which means I can take demo-sites to clients)

  13. A very useful article, for WordPress beginners, for creating test environments. Thanks a lot for such useful article & for sharing this article.. Thanks!

  14. Siobhan,
    Thanks so much for this. I was frustrated because I couldn’t figure out WHERE to put the wordpress folder. You told me! Quick and easy after much troubles elsewhere.
    -dan

  15. I installed xampp and dropped wordpress files into the htdocs directory. When clicking on index.php the browser tries to download the file father than run the php code.

    Any ideas as to what I have done wrong?

  16. I followed all your steps but when i run localhost/wordpress, I am getting

    Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

    Fatal error: Unknown: Failed opening required ‘C:/xampp/htdocs/wordpress/index.php’ (include_path=’.;\xampp\php\PEAR’) in Unknown on line 0

    How shuld i solve thsi? please help me

    • Hi Ezinne, I’ve just sorted the problem out with some help from a colleague. Here are his instructions:
      1. Install XAMPP – it should install to the root of a directory, so: C:\xampp rather than C:\Program Files\xampp
      2. Make sure it’s running okay – or at least Apache httpd and MySQL are.
      3. Create passwords for MySQL root user and directory protection (.htaccess)
      http://localhost/security
      4. Restart MySQL to enable the password to be picked up – it doesn’t work if you don’t do this.

      Then your wp-config.php file will look something like this:

      define(‘DB_NAME’, ‘your db name here’);

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

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

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

      /** Database Charset to use in creating database tables. */
      define(‘DB_CHARSET’, ‘utf8′);

      /** The Database Collate type. Don’t change this if in doubt. */
      define(‘DB_COLLATE’, ”);

      Hope this helps!

  17. Hi Siobhan, I found your tutorial very clear and easy to follow… however, I’m having the same problem as Ezinne. I get a page with ‘Error establishing a database connection’ when I try to link to the WP page. Any ideas why? Thanks.

  18. Have you tried DesktopServer Limited (serverpress.com). It’s free and allows you to create multiple, isolated, wordpress websites in just a few seconds (as it includes wordpress and everything needed to get running right away, has Xamp built in). This makes it easy to play around on one site (break it even), another to test plugins and themes, and another just for getting work done. It works on Windows and Macs. Here is a video:

Participate