Call now! (ID:220229)+44-20-3695-1294
HomeBlogHow to Copy WordPress Site to Local Test Server

How to Copy WordPress Site to Local Test Server

Why would you want to do this? If you have used the auto installation process to quickly set up your wordpress site and have customized it to your liking, you may later want to add more plugins, features, etc. In order to do this, it is probably best to do your changes to a copy of the site and if everything works out, you can then perform those same changes on your web server. In this way, you can apply whatever changes you make to the website without any downtime. I will explain easy step by step instructions on how to do this below.

A. Preparation. Installing your local web server

Prep 1. First, download xampp here and install. This will install linux, apache, mySQL, and phpMyAdmin on your pc so that now you have your own development server to test and/or develop wordpress installations (or any other website applications).

Prep 2. The default location on your pc will be: C:xampp and all web site files will be in: C:xampphtdocs

Prep 3. You will want to create a new folder for each of your websites inside of htdocs with any name you like, ex. testsite (C:xampphtdocstestsite)

Prep 4. To start xampp, go inside the C:xampp folder and double click xampp_start.exe (make sure when you later want to stop the server you click xampp_stop.exe located in the same folder. I create shortcuts to these files on my desktop)

Prep 5. Open up your browser and type http://localhost (you can also use you should now see the xampp welcome page

Prep 6. On the left menu towards the the bottom of the xampp welcome page click the link 'phpMyAdmin' under 'Tools'. When you are inside of phpMyAdmin and need to create a new database click the 'Databases' tab at the top and create a new database by filling in any name you like create_database

B. Copy the site to your local server

Before we start lets define a few things:

The hosted version address we will refer to as: (This is the web address of the hosted wordpress site) The local version address we will refer to as: http://localhost/testsite (This is the web address of the local host folder you want to transfer your site to)

Copy all files from your webhost to your local server folder (C:xampphtdocstestsite). Use an FTP prgram like Filezilla Client.

On your webhost, login to phpmyadmin and export your database (By Selecting your database and selecting the export tab and downloading to your computer) phpMyAdmin_export

Log into your local phpmyadmin (Prep 6 above), create a new database and import the sql database into it by selecting the import tab and uploading your file. phpMyAdmin_import/

Once uploaded we want to modify the database to reflect the new blog location being on the localhost. So we run the following SQL (Select the SQL tab and paste the following code):

UPDATE wp_options SET option_value = replace(option_value, '', 'http://localhost/testsite') WHERE option_name = 'home' OR option_name = 'siteurl';


Next, we now want to fix the urls of posts and pages. So we run the following SQL:

UPDATE wp_posts SET guid = replace(guid, '','http://localhost/testsite');

Then, if you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. So we run the following SQL to fix this issue:

UPDATE wp_posts SET post_content = replace(post_content, '', 'http://localhost/testsite');

We want to now modify our wp-config.php file in our local server. The easiest way to do this is to delete the wp-config.php file in your local server (C:xampphtdocstestsitewp-config.php) and then visit http://localhost/testsite in a browser. Skip to steps 8 - 10.

You can also open wp-config.php located in C:xampphtdocstestsite and edit these lines:
define('DB_NAME', 'yourlocaldatabasename'); (from Step 3)
define('DB_USER', 'databaseusername'); (usually 'root')
define('DB_PASSWORD', 'password'); (usually empty, looks like define('DB_PASSWORD', '');
define('DB_HOST', 'localhost'); (usually localhost, leave as is)
Skip steps 8 - 10, and you're done!

With the dialog message that comes up click the 'Create a Configuration File' button. Then click the 'Lets Go' button on the next screen.

Fill in all of the fields:
Database Name: This is the name of the database in your local phpmyadmin
Username: This is your phpmyadmin username (usually root)
Password: This is your phpmyadmin username's password (usually leave this field empty)
Database Host: This is usually localhost
Database Prefix: normally is wp_ unless someone has changed it manually.

STEP 10:
Click Submit, the wp-config file will be created and everything should work on the local host.

Tags: , , , , , , , ,