How clone your WordPress website onto your local Windows desktop

NOTE: This process will involve installing and configuring wamp on your desktop. Click here to learn how to install and configure wamp server.

The article won’t go through backing up your data from your host as there are many different ways that this can be done and is fairly straight forward – but if you would like a tutorial on how to do that please leave a comment below and if there’s enough interest I’ll create one.

There are many advantages for doing something like this but I think 2 of the most important are the following:

  • having a working development site is a much safer way to test plugins and themes so that if something does go wrong it won’t effect your live site
  • there are lots of plugins out there to back up your WordPress website BUT when was the last time you tested to make sure that your backup even worked???
    • this is a great way to test and make sure that your back up is ACTUALLY working!

Let’s get started!

Before we get started make sure you have your database in .sql or .gz format and that you have the “public_html” folder from your live site. If you can’t see the “public_html” you’ll most likely need to download the entire contents. It will depend on what access you have to your host.

Once you have these 2, copy them into the www folder in c:\wamp then rename the “public_html” folder to something more user friendly. In this case I’m using locslikes.

c:\wamp\www\locslikes

1a Rename to locslikes

 

Enter the folder and look for a file name “wp-config.php“. Right click on it and open it in your favorite text editor.

2 wp-config-php

The items we are interested in are the DB_NAME, DB_USER, DB_PASSWORD and DB_HOST.

2a wp-config-php

Just leave that up as we’ll need this information shortly. Next open up phpMyAdmin by clicking on the Wamp icon and selecting “phpMyAdmin

2 mysql phpadmin crop

Creating a Database

In “phpMyAdmin” go to “databases” and copy the database name from the wp-config.php file and insert it into the “create database” then click “create

3a add database

Once that’s created you’ll see it pop up on the left. Select the newly created database on the left of the screen. It will be empty as it’s a brand new database. Click “Browse” and select the database file that you downloaded from your live site. This can either be .sql or .gz file.

3b import database

Give it a few moments and you should see the database get filled with data on the left. Now look for “wp_options” and select it. It will bring up a whole bunch of information on the right half of the screen.

In row 1 and 33 where it lists the website domain change them both to “https://localhost/locslikes(replace with your folder name)

In row 27 next to the “permalink_structure” if you have “/%postname%/” delete it.

3c edit database url

That’s it for the database!

Adding a User

Now that we’ve created the database we need to create a user who can access it.

Click on the top where it says “server:localhost” this will take you back to the main menu where you can select “users” then click “Add User

4 add user

Put in the user information exactly as in the “wp_config.php” file into the spaces and make sure you change the “Host” to “Local” and it will automatically fill in “localhost”

4a user password

make sure you check “Grant all privileges on wildcard name” and “Check All

4b user privileges

click “Go” then you should see the new user with it’s privileges.

4c user privileges

If there were no errors during any of these steps then you should be good to go! Now to test it!

In your browser type into the address bar “https://localhost/locslikes(replace locslikes with your folder name) and give it a little time and it should load up what should be your website!

Congratulations on creating your very own development site!

NOTES:

There are some caveats to this method and it all depends on how heavily customized your website is.

Some of the issues you may encounter are:

  • If you use permalinks and manually type in the link and don’t let WP create the permalink structure then it won’t be able to find the link. You must go to the page and delete the custom name.
  • hard links won’t change. ie links to other areas on your site that have the full domain hard coded into the link will still point to the full domain

Please keep this in mind as there have been times I thought I was working on my localhost when it has actually taken me to the live site. One way to get around this issue is to disconnect your internet connection while doing changes to make sure.

Tags: