Are you a WordPress developer or enthusiast looking to set up a local testing environment? Moving a copy of your live WordPress site to your computer is a great way to:
- Test new themes, plugins and code without affecting your production site
- Develop locally and enjoy faster performance
- Learn WordPress development in a safe sandboxed environment
- Work offline without needing an internet connection
In this in-depth guide, we‘ll walk you through everything you need to know to migrate your live WordPress site to a local server on Windows, Mac or Linux.
Why Develop WordPress Locally?
WordPress powers over 40% of all websites according to W3Techs. With its huge ecosystem of themes and plugins, it‘s no surprise that many developers specialize in WordPress.
Using a local WordPress development environment offers several advantages:
It‘s completely separate from your live production site. You can safely experiment with code and configuration changes.
Developing locally is usually much faster than on a remote host, since you eliminate network latency. Delicious Brains found local development can be up to 3x faster.
You can build and test WordPress sites without an internet connection, perfect for coding on-the-go.
Using real data from your live site makes development and testing more representative than default WordPress content.
You have complete control over your local server environment and can customize to your needs.
But how do you actually get a copy of your live WordPress site running on your local machine? Don‘t worry, we‘ll cover two methods step-by-step: using a plugin and manually.
Prerequisites
Before we dive into moving WordPress locally, you‘ll need a few things:
- Access to your live WordPress site‘s files (via FTP/SFTP or hosting control panel)
- Access to your live WordPress database (via phpMyAdmin or hosting control panel)
- A local PHP development environment set up on your computer
There are several options for running a local web server, including:
- XAMPP – An easy to install Apache, MySQL, PHP & Perl distribution for Windows, Mac and Linux
- WAMP – A Windows web development environment
- MAMP – Local server environment for Mac
- Local – A popular WordPress-specific local development tool
All of these let you run WordPress on your own computer. We‘ll be using Local for this tutorial, but the same basic steps apply to other setups.
With your live site access and local server ready, let‘s look at migrating WordPress!
Method 1: Moving WordPress Locally Using a Plugin
The simplest way to move a live WordPress site to your local machine is using the free Duplicator plugin. It bundles your entire WordPress site into a single package you can easily download and install locally.
Follow these steps:
- Install and activate the Duplicator plugin on your live WordPress site
- Go to
Duplicator > Packagesand click the "Create New" button - Duplicator will generate an archive package of your WordPress files and database
- Download the
installer.phpand archive.zipfiles when ready - Upload both files to an empty folder in your local server‘s web root (usually
htdocsorwww) - Create a new database in your local MySQL server to house your WordPress data
- Visit the
installer.phpfile in a browser athttp://localhost/your-local-folder/installer.php - Follow the on-screen steps to extract the archive and import your live database to local MySQL
- Update the local site‘s URL and paths when prompted
- Access your local WordPress site in a browser and log in with your live credentials
That‘s it! You should now see an exact copy of your live site, but running from your local server. Super easy, right?
Method 2: Manually Migrating WordPress to Local Server
If you want more control or don‘t want to use a plugin, you can manually move your WordPress files and database.
Step 1. Download WordPress Files
Connect to your live WordPress site via FTP/SFTP or hosting file manager. Download your entire WordPress directory, including:
wp-adminandwp-includesfolderswp-contentfolder with your themes, plugins and uploadswp-config.phpand any other WordPress core files
Step 2. Export Live WordPress Database
Next, export your WordPress database from your live MySQL server using phpMyAdmin or hosting database manager:
- Log in to phpMyAdmin and select your WordPress database
- Go to
Exportand chooseQuickexport method - Select
SQLformat and clickGoto download the database dump file
Step 3. Import WordPress Files Locally
Extract the WordPress files you downloaded into a folder in your local web server directory. For example, in XAMPP the web root is C:\xampp\htdocs\ on Windows or /Applications/XAMPP/htdocs/ on Mac.
So if you wanted the local site at http://localhost/mysite/, you‘d unzip the files into C:\xampp\htdocs\mysite\ on Windows.
Step 4. Create Local WordPress Database
Next, create an empty database on your local MySQL server to import your live data into. In phpMyAdmin:
- Click
Newto create a database, for examplemysite - Select the
utf8mb4_general_cicollation
Step 5. Import Live WordPress Data
With the empty database created, import your live WordPress database export file:
- Select your empty local database in phpMyAdmin
- Go to
Importand browse for your exported.sqlfile - Leave the default settings and click
Goto run the import
phpMyAdmin will populate your local database with a copy of your live WordPress site‘s data.
Step 6. Configure Local wp-config.php
Open the wp-config.php file in your local WordPress directory. Update the database connection details to match your local setup:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( ‘DB_NAME‘, ‘mysite‘ );
/** MySQL database username */
define( ‘DB_USER‘, ‘root‘ );
/** MySQL database password */
define( ‘DB_PASSWORD‘, ‘‘ );
/** MySQL hostname */
define( ‘DB_HOST‘, ‘localhost‘ );Replace mysite with the name of the database you created. The root user with no password is the default in most local server tools.
Save the wp-config.php file.
Step 7. Update Database URLs
Finally, in phpMyAdmin, run the following SQL queries on your local WordPress database to update all URLs to reference your local site instead of the live one:
UPDATE wp_options SET option_value = replace(option_value, ‘http://www.live-site.com‘, ‘http://localhost/mysite‘) WHERE option_name = ‘home‘ OR option_name = ‘siteurl‘;
UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.live-site.com‘, ‘http://localhost/mysite‘);
UPDATE wp_postmeta SET meta_value = replace(meta_value,‘http://www.live-site.com‘,‘http://localhost/mysite‘);Be sure to replace http://www.live-site.com with your actual live WordPress site URL and http://localhost/mysite with the URL to your local WordPress folder.
Access your local site in a browser at http://localhost/mysite/wp-admin/ and log in. You should see your live site data and be able to work on a local copy!
Syncing Local and Live WordPress Sites
With a local copy of your WordPress site set up, you can develop new functionality much faster. Make sure to keep your local environment in sync with your production site, especially the database.
Some helpful tools for syncing databases between local and live:
- WP DB Migrate – Push and pull databases
- WP Sync DB – Sync databases via a CLI
- VersionPress – Version control for WordPress databases
Ideally, get a fresh copy of your live database before starting a new development cycle locally. Then you‘ll be working with the latest content.
Pushing changes from local back to production is trickier. We recommend using Git version control and only deploying files you‘ve actually changed. Keep your local wp-content folder under version control and deploy to the corresponding live directory.
Be extremely careful directly overwriting your production database with local data. It‘s safer to manually migrate specific configuration changes to live.
Troubleshooting Local WordPress Issues
If you followed the steps above, your local WordPress site should work right away. But sometimes you may encounter issues.
Fixing Local Site URLs
If you see broken images and styles on your local site, the most likely cause is wrong URLs in the database. Make sure you update all instances of your live URL to the local one.
You can use the Better Search Replace plugin to easily find/replace URLs in your local database.
Increasing Local Server Resources
Your local environment may have more limited resources than your production server. If you run into slowdowns or errors, try increasing your local server‘s:
- PHP memory limit
- MySQL buffer pool size
- Apache MaxClients
- NGINX worker connections
Consult your local server tool‘s documentation for steps to adjust these resource settings.
Enabling WordPress Debug Mode
WordPress comes with a handy debug mode that shows detailed error messages. To enable:
- Open your local site‘s
wp-config.phpfile - Locate or add the following lines and change
falsetotrue:
define( ‘WP_DEBUG‘, true );
define( ‘WP_DEBUG_DISPLAY‘, true );Save the file and reload your local site. You‘ll now see detailed error messages to help troubleshoot issues. Just remember to disable debug mode on production!
Useful Local WordPress Development Tools
To streamline your WordPress development workflow, there are several excellent free tools:
- WP-CLI – Manage WordPress from the command line for faster setup/config
- Prospress WP Data Generator – Generate realistic dummy data for testing and benchmarking
- WP-DBManager – Helpful tools for WordPress database backup/restore, search/replace and tweaking
- Local Addon for VS Code – Run WP-CLI and control your Local sites directly from the code editor
We also recommend getting familiar with your local server stack‘s tools, like phpMyAdmin, PHP config files and Apache/NGINX settings. The more you understand your environment, the easier local WordPress development becomes.
Moving a Local WordPress Site to Live Production Host
Once you‘ve perfected your local WordPress site, you‘ll need to migrate it to a live web hosting account. The basic steps are:
- Export your local WordPress database
- Import it into your hosting account‘s MySQL database
- Upload your local WordPress files to production via FTP
- Update the live site‘s
wp-config.phpwith production database details - Change all local URLs to live ones in the production database
You can automate much of this with the Duplicator plugin‘s "package" feature or explore hosting-specific tools like:
Check your hosting provider‘s documentation for guides to move local WordPress to their platform.
Further WordPress Local Development Reading
Hopefully this in-depth guide helped you successfully create a local copy of your WordPress site! It‘s a key skill for efficiently developing themes, plugins and sites.
To dive even deeper into local WordPress workflows, check out these excellent resources:
- WordPress XAMPP Step by Step Guide
- Guide to Building Web Apps Locally with MAMP & WordPress
- How to Use the WP-CLI
- Top 5 Benefits of a Staging Environment in WordPress Development
Running WordPress locally gives you a safe space to learn the world‘s most popular CMS platform. Let us know how your migration went in the comments!
