How To Copy A Live WordPress Site To Localhost Manually
May 27th, 2018 | by Ravi Chahar || 8 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 into 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 into 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 into the right folder.
Step 5:- Create a new database on your localhost. Just open “localhost/phpmyadmin” and you will see the same phpMyAdmin as you see on your live server.
Create a database from the left menu and import database file you have downloaded in the first step.
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 localhost 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 Migration
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.
Hi Ravi !
Thanks for sharing this amazing tutorial. But this is the common solution. I am looking for moving multi-site to local-host. Did you have any experience in multi-sites migration?
Have A Good Day !
To move many sites together, you have to create the databases for each website. Put each website is a separate folder of the localhost. The process is quite similar as explained above.
The only difference is that you have to choose the place for the data of each website.
Great tutorial, Ravi. I’ve never done it this way. You know I’ll be saving this one and adding it to my Blogging Love Tutorial library. 🙂
I am glad that you found it helpful. As you’re into web designing then you would love to have a copy of your online website with you to test your designs.
Thanks for supporting.
Have a great week ahead.
It is a super cool post, and you made it very simple for newbies as well. Liked the guide. Yes, most of the bloggers who are techies, do keep their blogs backed up on localhost too to test the plugins and themes first before putting online.
Enjoy the winter!
People really need a guide which can help them to improve their skills. It’s good to have the backup of your live website on the local server.
Testing is one of the phases of the web development and people really need that.
Thanks for taking the time to share your views.
Have an awesome day.
You have written great post Ravi! You made it very much easy with demonstration which will be easy for newbies and me also. It’ll help me a lot
What a great share! I have a friend who wants to copy his website and host it manually. I think this will be a great post for him. I learned several tips that will help me if I had to do this in future, and I will definitely share this article with him to ensure he follows the right process. It was a great read, and a very helpful resource. Thanks a lot for sharing this, I look forward to reading more of your helpful articles.