How to Install WordPress on XAMPP: Run WordPress Locally 2

Whenever I want to try a new WordPress theme or  make significant changes to my blog, I prefer to test it out on my own computer first rather than dabble with my live site and run the risk of crashing it for all the world to see.

Having WordPress installed locally on your own computer can save a lot of anxiety. This is especially true if you want to roll out a new version of your site. or perhaps convert it to a new WordPress theme. 

Professional WordPress: Design and Development

But WordPress needs to run on a server.

When we talk servers we are usually referring to the web servers provided by hosting companies. This is where we house our live sites.  

So how can we have access to a local server?  Simply by setting up a local web server  on our own computer. This is where applications like XAMPP, for example, come to the rescue. 

Please Note:
This article doesn’t cover installing XAMPP but it does provide you with an expert link that will guide you through the process step-by-step.
What this article does cover is:
1. How to install WordPress on XAMPP on your own computer.
2. How to copy your live WordPress site, from where it is hosted, to your local WordPress installation.

Setting Up Your Own Local Server

I don’t know how many times I have cloned my live site locally but nearly every time I trip over one of the required steps and then have to refer to some crude notes I scribbled the last time I did it.

So this post is designed to help people who find themselves in the same boat. That is, I am presenting steps here that you can follow each time you want to create another install of your website or blog on your local machine. I am also writing it for myself so that I can quickly refer back to this post anytime I want to implement a new website installation locally.

How to Install XAMPP

There are  a number of different applications that will allow you to install a development testing environment on your own computer. For example you could just as easily use MAMP or WAMP.  But XAMPP is the application that I am most familiar with so it is the environment that I refer to in this article.

It can be a little tricky to set up a platform like XAMPP, but once you have it installed, it is plain sailing from then on.

If you already have XAMPP installed on your computer then you can skip this section and jump right to the following section about installing WordPress on XAMPP and/or the section on copying your live site to your local WordPress installation. 

Otherwise read on for some handy links that will help you install XAMPP.

In case you are wondering, the letters XAMPP stand for: 

  • X – Cross platform  (can work on Windows or Macs or Linux etc.)
  • A – Apache
  • M – MySQL
  • P – PHP
  • P – Perl

You probably didn’t need to know all of that but now that you do, we are off and running.

You can download XAMPP here.


As mentioned, this post primarily addresses steps to take when you already have XAMPP installed. Therefore, if you don’t have a local installation of xampp, here is a very good tutorial to help you get started: How to Install XAMPP for Windows. (I simply installed XAMPP on drive C.)

Alternatively, if you are looking for more help on using WordPress to create your site, then both of these Skillshare couurses (affiliate links) include a module on installing an XAMPP server:

If you experience any problems in starting the XAMPP control panel, try running it as an Administrator:

  1. Right click on the XAMPP icon.
  2. Click on Run as Administrator.

How to Install WordPress Locally on XAMPP

You can of course use XAMPP for other platforms as well such as Drupal and  Joomla etc., but here I am addressing WordPress only, my preferred website platform.

Installing WordPress locally on XAMPP can be straight forward once you are used to it but it can also be a little daunting if you have never tried it before.

And if forums are anything to go by, a lot of people stumble over this and are looking for a helping hand.

So hopefully these steps will help you along the way.

  1. Start XAMPP

    Start XAMPP if it is not currently running and click first on the Start button for Apache. Wait until it turns green and then click on the Start button for MySQL. 

    XAMPP Control PanelRemember if you have any difficulties here, run it as an administrator (by right clicking the icon).

    Load a browser window and enter the following to make sure that XAMPP is running:

  2. Create a New Database for Your WordPress Website

    Return to the XAMPP Control Panel and click on the Admin button in the MySQL row.

    This will open up a new window with the phpMyAdmin dashboard.

    If it wasn’t previously opened then you will be prompted for your login.
    Most likely, your username is still root and the password empty.


    Click on Databases from the top menu in the phpMyAdmin dashboard. 

    In the textbox beneath Create Database, enter a name for your database. This can be any name, but make it simple without spaces. If I am experimenting with a new theme I might give it the initials of my site followed by a shortened version of the theme. Or I might include the month and year in the name. It is up to you. But for clarity in the following explanations, I will use the name newlocalsitedb.

    Once you have entered a name you are happy with, click Create.

  3. Download WordPress

    Download WordPress. You can find the most up-to-date version here.

    Unzip the WordPress download and extract all files.  You’ll see that the extracted folder name includes the version of WordPress as well and inside this folder is another that is simply called WordPress.

    Rename the inner WordPress folder.  I usually use a name that is similar to the name I used for the database, in this case I’ll use newlocalsite .

    Open the folder where you installed XAMPP and then open the folder called htdocs. Move your newly-named WordPress folder, newlocalsite, inside the htdocs folder.

  4. Configure wp-config.php 

    Open the newlocalsite folder (htdocs/newlocalsite) and rename the wp-config-sample.php file to wp-config.php .

    Right click the wp-config.php file and click on Edit. This will open the file in notepad.  Find these lines:

    wp-config.php modifications

    Now you can make the following changes:

    a) Replace  ‘database_name_here’ with the name of your database, e.g. ‘newlocalsitedb’
    b) Replace ‘username_here’ with ‘root’ and
    c) leave ‘password_here’ empty like this:  ”

    Save wp-config.php.

  5. Complete Local Installation of WordPress

    Refresh your browser window with http://localhost/ in the address bar.

    This will show you a listing of folders (if more than one) that you have installed. Click on the name of your new installation. (If nothing happens, check that you have entered the correct database name in the wp-config.php file.)

    When all is working as it should, you will now see a series of prompts. You might be asked to select your language.

    Then you will see the Welcome screen that looks like this:

Install WordPress

Follow the prompts to enter the required information:

Site Title: e.g. New Local Site 
Username: Root
Password:  chooseYourPWD

Click Install WordPress.  You should now see Success.

Click on Log in  This will be the username and the password that you just entered.

Now you have WordPress installed locally on your own computer.

If you preview your site you will see something pretty bland but it IS a working WordPress site:

Default Theme in WordPress

At this stage it displays the latest default WordPress theme. You can now choose or upload any theme that you like via Appearance-Themes.


How to Copy a Live WordPress Site to Your Local Server (XAMPP)

Now this section will help you take an existing site, that is already live on your hosting server, and make a copy to install on your own computer (on your XAMPP server). 

  1. Backup Live Site Files & Database

    Backup your live site to your computer by following the steps listed in this post on Backing up a WordPress site.

    Following these backup steps, you will end up with a copy of folders and files from the live site.

    You will also have downloaded a zipped version of your database file.

  2. Create a New Empty Database

    Activate phpMyAdmin again on your local site.
    Click on Databases and create a new one; I’ll call this one, for this example, testsitedb because often the purpose of having a copy of your live site is so that you can test changes.

  3. Import the Database Downloaded from Your Live Site

    Click Import and browse for the zipped database file you just downloaded from your live site.

    Import Database to Local ServerIf your live site is rather large, this importing step can take a little while. 

    When it is finished, you should see a success tick:

    WordPress database import

  4. Copy Backup Folder

    Make a copy of your site’s backed up folder and rename the copied version. For this example, I will call this folder testsite.

    Move the testsite folder into htdocs.

    Rename your htaccess file htaccessbak.

    Edit wp-config.php and change the database name to your newly created database (e.g. testsitedb), the username to root and empty the password field by removing the letters inside the ” marks.

    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘testsitedb’);
    /** MySQL database username */
    define(‘DB_USER’, ‘root’);
    /** MySQL database password */
    define(‘DB_PASSWORD’, ” );

    Save wp-config.php.

  5. Update URLs in Database File

    In step 3 we imported a copy of the live database into our newly created database, testsitedb. However, if you were to look in the Options table, you would see that many of the pathnames still refer to the live site. We want them to point to the local site.  And we can easily update these pathnames with an SQL command, as follows.

    From the phpMyAdmin dashboard, click on SQL and paste the 3 code statements listed below but before you click Go, make sure that you change livesitename to your own and the testsite name to the name of the folder you created on the localhost, in my case it is in fact testsite.

    UPDATE wp_options SET option_value = replace(option_value, '', 'http://localhost/testsite') WHERE option_name = 'home' OR option_name = 'siteurl';
    UPDATE wp_posts SET post_content = replace(post_content, '', 'http://localhost/testsite');
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'','http://localhost/testsite');
  6. Test Local Site in Browser

    Now go to your browser and enter 

    You should see your testsite folder listed. 

    Click on it. You should see your home page loaded locally. (If instead you see “Error establishing a database connection” then check that wp-config.php has the right database name. )

  7. Fix Object Not Loaded Error

    The URLs have been modified but when you try to click on a link, you will see “Object Not Loaded”.  This is because the Permalinks need re-saving:

    To fix it, enter the local WordPress admin dashboard. When accessing admin, you will be prompted to login again as it is now expecting the username and the password that was used for your live site:

    Click on Settings – Permalinks
    There is no need to change them, just click save.

    Now you should be able to click on the links in your site when you view it.

  8. Have Creative Fun with Your Local Site

    Have fun with your local installation.

    I know that I am much more adventurous in trying out different configurations on a local server, knowing that I am only affecting a local version, not my live site.

    When you are happy with your changes you can simply migrate them to the live site or update your live files to reflect the changes.

  9. Tidy UP

    When you have finished working with your local environment you close XAMPP by clicking the respective Close buttons in the XAMPP window, first MySQL and then Apache.

Building Websites With WordPress – Training DVD



Leave a comment

Your email address will not be published. Required fields are marked *

CommentLuv badge

2 thoughts on “How to Install WordPress on XAMPP: Run WordPress Locally

  • Jack Vaniyo

    I am trying to install WordPress on local host but I always get error with the database. What could be the possible reason for that? I am using XAMPP for the installation on local environment.

    Is there any easy solution like softaculous/ fantastico on XAMPP?

    • Glenys Grob Post author

      Hi Jack,
      What error message did you receive?

      I am assuming that you are trying to install WordPress for the first time on XAMPP or are you trying to copy a live site to XAMPP?
      Softaculous & fantastico are provided by a hosting service for a live site installation.

      Have you followed the steps I have included under the heading “How to Install WordPress Locally on XAMPP”?
      Check that wp-config.php has the same database name as the one you just created in phpMyAdmin – see step “Configure wp-config.php”.