How To Copy A Live WordPress Site To Localhost Manually?
December 26th, 2016 | by Ravi Chahar || 6 Comments |
There are many people who have a copy of their website on their localhost to test the plugins and themes.
It’s another step towards the WordPress security. Before you use any new plugin, you can test it on your localhost with the same data of your website present on the online server.
In this tutorial, you will learn how to copy a live WordPress site to localhost without using any plugin.
A few people go with the duplicator plugin but it’s always good to follow the manual methods.
Whether you transfer WordPress site from a localhost to server or you move WordPress to another domain name, you should have the full backup to your computer.
Steps To Move A Live WordPress Site To LocalHost.
Most of the people follow the wrong path and break their website.
You just have to follow a step by step guide to accomplish this task.
Step 1:- You have to backup WordPress database of your live website from cPanel>>phpMyAdmin>>export.
Step 2:- You will see many options while exporting the database. You should choose the custom method and leave the tables which are generated by the plugins.
It’s because many plugins add their own tables in the database and you don’t need those tables on your offline server. You will come to know by the names of the tables.
Just choose the database tables which are related to WordPress.
When you scroll down, you see the type of the file which should be downloaded. Choose the ZIPPED file from the drop down menu.
Scroll down and click the button to download the database. It will get downloaded within a few minutes depending on the size.
Step 3:- Now you have to download all the files of your website from the cPanel>>file manager>>public_html.
Select all the files and compress them in a single ZIP file so that you can easily download the backup of your whole website.
If you have already moved your website to any other folder then copy that folder otherwise, just go with the flow.
Click on the ZIP file to download the backup.
Step 4:- You should copy and paste all the files of your live website in your local website folder.
Extract the files from the backup of your website. Copy and paste them in the local website folder. For example, “mysite“.
You can choose the folder’s name anything you want.
To copy a live WordPress site to localhost just make sure that you paste all the files in the right folder.
Step 5:- Create a new database on your local host. Just open “localhost/phpmyadmin” and you will see the same phpMyAdmin as you see on your live server.
If the size of the database is bigger then you have to increase phpMyAdmin import file size limit in XAMPP.
It’s because on the local server, by default, the file upload limit is only 2 MBs. To import the bigger database file, increase the upload file limit.
Step 6:- You have successfully imported the database and the WordPress files of your live website on the local server.
Now is the time to set the URL of the website.
Go to phpMyAdmin of your local server and click on the SQL from the menu bar.
Add the code in there.
UPDATE wp_options SET option_value = replace(option_value, ‘http://www.livesite.com’, ‘http://localhost/mysite’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.livesite.com’, ‘http://localhost/mysite’);
UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘http://www.livesite.com’, ‘http://localhost/mysite’);
NOTE:- Don’t forget to replace “http://www.livesite.com” with the URL of your online website and “http://localhost/mysite” with the URL of your local website.
It’s important because all of the queries of the database are still running the URL of your live website.
You should make them use the local URL so save the SQL query after adding the code.
Step 7:- This is the final step.
As you all know, you have created the new database on the local server and the database information stored in the wp-config.php file is of the live website.
If you want to copy a live WordPress site to localhost then you have to update the database information.
Go to your local host and edit the wp-config.php file.
Search for the codes showing the name of the database, password, user name etc.
Fill all the information of your local database and save the file.
If you don’t update the information then you will see “error establishing a database connection“.
You have successfully accomplished the task to copy a live WordPress site to localhost.
Now, you can begin your testing sessions.
If you’re a theme developer then use your live website on the local server.
Did You Find Anything Difficult During The Website Moving Process?
From the database to the data of your website, you should move everything to your local server.
Did you face any difficulty? Is there something you would like to ask? WordPress seems to be hard, but if you follow the step by step guide, you can easily complete the task.
Make sure that you backup your database and all the files of your website before you copy a live WordPress site to localhost.
If you still face any problem, I am here to help you.