How to Move a Live WordPress Site to a Local Server: An Expert‘s Step-by-Step Guide

As a webmaster with over 15 years of experience working with WordPress sites, I highly recommend migrating your live WordPress site to a local server for development and testing.

In this comprehensive guide, I‘ll share my proven step-by-step process for smoothly and safely moving a live WordPress site to a localhost environment. Whether you‘re a beginner looking to learn or an expert webmaster yourself, follow these best practices to get your local WordPress copy set up correctly.

Why Migrate Your Live Site to a Local Server?

Before jumping into the how-to, let‘s first understand why you should migrate your live site in the first place:

  • Test changes safely – Develop, experiment, and test new plugins, themes, custom code, etc. without worrying about breaking your live site. No visitors will see half-finished work!

  • Develop new features – Add new website features, redesign layouts, try new widgets, etc in a safe sandbox environment.

  • Learn WordPress – Experimenting on a localhost copy is a great way for beginners to learn WordPress without risk.

  • Troubleshoot issues – If your live site is having problems, reproduce on a local copy to safely diagnose issues and test fixes.

  • Back up your site – Migrating to local creates a handy backup of your live site‘s files and database.

According to HostingTribunal‘s 2021 report, 73% of webmasters use local development environments to build, test, and back up their sites. And WordPress officially recommends working on a copy locally before deploying changes to your production site.

Step 1 – Set up a Local Web Server

The first step is installing local server software on your computer. This will mimic a live web hosting environment, allowing you to access WordPress locally via http://localhost/.

I recommend either:

  • WAMP (Windows) – Installs Apache, MySQL, PHP on Windows PCs. Easy to use.

  • MAMP (Mac) – Mac version of WAMP. Just as easy for MacOS users.

  • XAMPP (Cross-Platform) – Works on Windows, Mac, Linux etc. Very customizable.

These packages bundle the Apache web server, MySQL database, and PHP programming language to create a fully functional local web server on your computer.

Once installed, you can start your local servers and begin accessing sites at URLs like http://localhost/mysite.

Step 2 – Create a Local Database with phpMyAdmin

Before backing up your live site, we need to create an empty MySQL database on your localhost that you can import your WordPress data into.

Access phpMyAdmin at http://localhost/phpmyadmin and click on the "Databases" tab. Then enter a name for your new database, like local_wordpress and click Create.

This will create an empty database ready for us to migrate your live database to in the next steps.

Creating a new database in phpMyAdmin

Step 3 – Backup WordPress Files from Live Site

Now it‘s time to get a complete copy of your live WordPress site‘s files. This includes all folders and files like plugins, themes, uploads, etc.

Use FTP, cPanel, or another method to download your entire WordPress files/folders structure from your live hosting account to your local computer.

You want an exact 1-to-1 copy of your current live site‘s files to migrate to local.

Tip: Use a tool like Duplicator plugin to backup files & database easily in one go.

Step 4 – Export the Live WordPress Database

Next, we need to export your live WordPress database as an SQL file to migrate it to the local database.

Login to phpMyAdmin on your live host server, select your current WordPress database, click Export tab, and export the database.

  • Make sure to select all tables when exporting for a complete backup.
  • Choose custom export and zip compression for best results.

This will create a SQL file with your entire database contents ready for import to localhost.

Step 5 – Import Database to Local Server’s phpMyAdmin

Now log into phpMyAdmin on your local server and select the new empty database you created earlier.

Go to Import tab, choose your live WordPress database SQL file you exported, and click Go to import it.

This will migrate your live database to your local WordPress database.

Step 6 – Configure Local wp-config.php File

Next, we need to connect your local WordPress installation to the new local database you imported.

Open and edit wp-config.php in a text editor, and update the following settings:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( ‘DB_NAME‘, ‘local_wordpress‘ ); 

/** MySQL database username */
define( ‘DB_USER‘, ‘root‘ );

/** MySQL database password */
define( ‘DB_PASSWORD‘, ‘‘ ); 
  • Set DB_NAME to your local database name
  • Set DB_USER to your local database username, usually root
  • Set DB_PASSWORD to your local db password if you have one. Otherwise leave blank.

This will connect your local WordPress site to your local MySQL server and database.

Step 7 – Upload Files and Complete Local Installation

Now all that‘s left is to upload your live WordPress site files backup to your local servers installation location usually /htdocs/ or /www/.

This may require fixing file permissions on localhost.

Access /wp-admin on your local WordPress site. It will take you through the WordPress installation. Use the same site title, admin username, password, and details as your live site.

Finally, update Site URL and Home URL to local URLs like http://localhost/mysite and your migration will be complete!

Expert Tips for Seamless Local WordPress Migrations

Here are some pro tips from my experience for smooth trouble-free migrations:

  • Always backup your live site before migrating including files and database dumps.

  • Use Duplicator, All-in-One WP Migration, or WP Migrate DB Pro plugins to automate migration.

  • Adjust localhost file permissions to 755 for folders, 644 for files to avoid issues.

  • Clear all caches and test site thoroughly on localhost before making changes.

  • Update hardcoded links: Use Velvet Blues Update URLs plugin or better an SQL script.

  • Migrate a staging copy of your live site instead of production for zero downtime.

  • Index tables after import using phpMyAdmin for better performance.

Let me know in the comments if you have any other tips! I hope this step-by-step expert guide helps you successfully move your live WordPress site to a local server for development or testing. Feel free to reach out if you need help.

Written by Jason Striegel

C/C++, Java, Python, Linux developer for 18 years, A-Tech enthusiast love to share some useful tech hacks.