Bloggers, have you ever been in the situation where you want to make changes to your site (such as changing of theme, installing new plugins etc), but afraid that it will break your site? A lot of time, we wish to implement some changes and see how it looks like on the live site, without actually making it live. In such cases, the best solution is to create a local server (aka test server) and clone your live site to the local server. In this way, you can first test out the changes on your local server and make it live only when you have confirmed everything is working well.
What you will need:
- a local server application (we recommend XAMPP since it is the easiest to use and it works for all platforms)
- a copy of the WordPress software (download it from WordPress.org
- a copy of your existing WP blog database
- a FTP program (We will be using Filezilla, but you are free to use your favorite application)
Let’s get started.
Installing WordPress in your local server
I won’t go into much detail here since we have previously written plenty of articles on this. Check them out:
Note: Resume this tutorial only after you have installed WordPress in your local server.
Backing up your live WP blog
You will need to get a backup copy of the database of your live WP blog. This can be achieved in two ways: plugin or phpMyAdmin.
Install the WP-DB-backup plugin and go to Tools -> Backup in your WordPress dashboard.
Check all the tables name.
Select “Download to computer” and click “Backup now!”.
The backup process will begin and it will prompt you to download the sql file when it is done.
Login to your web host cPanel and click on the phpMyAdmin icon.
In the left pane, click on your WP blog database.
Click the Export button.
Scroll down to the bottom of the page. Check the box “Save as file“. Also check “gzipped”. Click Go.
Restoring the database in your local server
Start your local server. Open a browser and go to “http://localhost/phpmyadmin”. Create a new database.
Next, click on the “Import” button.
Navigate to the location where you save the database file. Click Go.
This will import your WordPress database to your local server. If your database file is more than 2MB, you might need to increase the “upload_file_limit” variable in the php.ini file.
Configure the wp-config file
In your file manager, go to the WordPress folder within the htdocs folder. Open your wp-config.php file in a text editor and change the following:
//unless you have changed the setting, else the default will be as follow define('DB_NAME', 'wordpress'); //change this to the name of the database you have created earlier define('DB_USER', 'root'); define('DB_PASSWORD', ''); //no password by default. Change this if you have added password during installation define('DB_HOST', 'localhost'); //99% you won't have to change this
You need to add in another 2 lines:
That’s it. You have successfully cloned your live WP blog to your local server. You can login to your dashboard via the link “http://localhost/wordpress/wp-login.php” and make changes to your test site.
- To make the permalink work properly, you will need to regenerate the permalink structure in the Permalink setting page and edit the .htaccess file)
- For better compatibility, you might want to replace your wp-content folder in the local server with the one in the live site.
Image credit: thatcanadiangirl
Receive the latest update in your inbox.
Or connect with us: