How to Move a Live WordPress Site to Local Server

183

After learning how easy it is to install WordPress on local server in Windows or Mac, some of our beginner level readers asked us how they can move their live WordPress site to local server. We have previously showed you how to move a a WordPress site from local server to live site. This article is an exact opposite of that. In this article, we will show you how to move a live WordPress site to local server.

Why and Who Would Want to Move a live WordPress Site to Local Server?

A lot of people create a copy of their live site on local server to test new themes, plugins, or do development testing. This allows you to set up your theme with all your content and test all the features without worrying about breaking your site. Many users copy their site to local server to practice their WordPress and coding skills with actual site data.

Even though you can do all the testing with dummy content in WordPress, real site data gives you a better visual representation of how these changes will appear on your live site.

Important: Whether you are moving your WordPress site to a new domain, or from WordPress.com to self hosted WordPress, or to your localhost, it is highly recommended that you backup your entire website first. We recommend using BackupBuddy to create backups. You can also backup your site using BackWPUp, or create a manual backup.

Moving Live WordPress Site to Local Server using Plugin

First thing you need to do is install and activate the Duplicator plugin on your live site. Duplicator plugin allows you to create duplicate package of your entire WordPress site. It can be used to move your WordPress site to a new location, and can also be used as a backup plugin. Upon activation, the plugin adds a new “Duplicator” menu item in your WordPress admin sidebar. Clicking on it will take you to the packages screen of the plugin.

Create a new package in the Duplicator plugin

To create a new package, you need to click on the create new package button. Duplicator will start creating a package of your entire WordPress site. This may take a while, depending on how much data you have on your live site. Once finished it will redirect you to the packages screen, showing newly created package with a installer file. To move your site you need to download both, the zip package, as well as the installer file to your computer.

Duplicator Zip Package and Installer file

Your local server site will need a new database, so you need to create a database on your local server using phpMyAdmin. Once you have created the database you need to copy paste the package and install file to an empty folder in your local server’s web directory. To run the installation script, you need to open the install file in your web browser. For example if you pasted both files in /test-site/ folder you will access them in your browser by visiting http://localhost/test-site/install.php. You will now see the Duplicator installation script like this:

Running duplicator install script on localserver

On this screen, you need to provide your local server’s database information. The host is usually the localhost. If you have not created a new user for MySQL on your site, then your username would be root. If you are using a password for the root user then enter that password, otherwise leave it blank. Lastly, you need to enter the database name you just created.

The installer will now extract your database and WordPress files from the zip package and import them. Depending on the size of package, this may take a while. Once the installer has extracted the files and imported database, it will redirect you to the update page.

Updating URLs in Duplicator plugin for WordPress

On the update page, you need to provide the URL of your live site and the URL of the site on your local server. The plugin will automatically detect these values make sure they are correct and then click on the update button. Duplicator plugin will now update URLs in your database.

Succesfully copied your live site to local server

That’s all, you have successfully moved your live site to local server. The installer will show you a success page. You would also need to update permalinks on your local server site and delete the installer file and package.

Manually Move a Live WordPress Site to Local Server

In case the plugin does not work for you, then you can always manually move your live site to local server. The first thing you would need is to back up your website manually. We have a tutorial on how to backup your WordPress database manually. We recommend using phpMyAdmin to export your WordPress database.

To export your live site’s WordPress database, you need to log into your cPanel dashboard and click on phpMyAdmin. Inside phpMyAdmin you need to select the database you want to export and then click on the export tab on the top.

Export tab in phpMyAdmin

phpMyAdmin will now ask you to choose either quick or custom export method. We recommend using custom method and choosing zip as the compression method. Sometimes WordPress plugins can create their own tables inside your WordPress database. If you are not using that plugin anymore, then the custom method allows you to exclude those tables. Leave rest of the options as they are and click on the Go button to download your database backup in zip format.

Custom export options in phpMyAdmin

Once you have downloaded your database backup, the next step is to download your WordPress files. To do that you need to connect to your WordPress site using an FTP client like Filezilla. Download all your WordPress files and folder to your computer. Downloading all your files may take a while depending on how much data you have on your website.

Download all your WordPress files and folders through FTP

After downloading your WordPress files, if you downloaded all your files and not just the wp-content directory then simply copy paste these files in your local server folder where you want to install WordPress.

On your local server, you need to create a database for your WordPress site. To do that you need to open http://localhost/phpmyadmin/ in your web browser and create a new database. After creating the database click on the Import tab on top. On the next screen you need to click on the Choose File button to select the WordPress database export file you downloaded earlier, and then click on the Go button. phpMyAdmin will now import your database and will show you a success message when it is done.

Importing your database through phpMyAdmin

Now that your database is all set up, you need to update the URLs inside your WordPress database referencing to your live site. You can do this by running an SQL query in phpMyAdmin. Make sure you have selected your local site’s database and then click on SQL. In phpMyAdmin’s SQL screen copy and paste this code, make sure that you replace example.com with your live site’s URL and localhost/test-site with the local server URL of your site.

  UPDATE wp_options SET option_value = replace(option_value, 'http://www.example.com', 'http://localhost/test-site') WHERE option_name = 'home' OR option_name = 'siteurl';     UPDATE wp_posts SET post_content = replace(post_content, 'http://www.example.com', 'http://localhost/test-site');     UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.example.com','http://localhost/test-site');

This query will replace refences to your live site’s URL from database and replace it with the localhost URL.

The final step is to update your local site’s wp-config.php file. You need to go to the folder where you installed WordPress on your local server and open wp-config.php file in a text editor like Notepad. Replace database name with the one you created in phpMyAdmin on your localhost. Replace the username with your local mysql username, usually it is root. If you have set password for mySQL user root on your localhost, then enter that password. Otherwise leave it empty and save your changes.

  /** The name of the database for WordPress */  define('DB_NAME', 'database_name_here');    /** MySQL database username */  define('DB_USER', 'username_here');    /** MySQL database password */  define('DB_PASSWORD', 'password_here');

That’s all your live site is now copied to your local server, and you are ready to test drive it. We hope that you found this tutorial helpful. If you have any questions or feedback, then please leave a comment below.