Whether you are are doing testing or creating a new theme, there may be a time in your WordPress life that you will need to move a live WordPress website to a localhost web server. But lucky for you, you can move your WordPress website to a local server with quickly and with ease.
How to Move Life WordPress Website to Localhost Server
- Create a full backup of your live WordPress website
- Backup your MySQL database using phpMyAdmin
- Install a localhost web server
- Extract your WordPress website backup on the localhost server
- Import your MySQL database on your localhost server
- Update the wp-options table in the localhost database
- Update your wp-config.php file
- Enjoy your WordPress website on your local server
Step 1: Create a full backup of your live WordPress website
Once you are ready to move your WordPress website, you will need to create a full backup of your live WordPress website. You can either use a web based file manager like cPanel. Or use an FTP client. Either works.
On cPanel, open the File Manager application. Browse to the directory that your live WordPress website is installed to. For most websites, it will be located at /home/YOUR_USERNAME/public_html. Usually you can just click on the public_html link in the File Manager.
Once you find your live WordPress website, click on the “Select All” button then “Compress”.
This will give you a popup window to create a zip archive of your entire website (aka a full backup of your live WordPress website).
Check the box for “Zip archive”, then click the “Compress Files” button. You should a get a short loading message followed by a success message.
Now from the File Manager, find the zip archive you just created. Usually, the File Manager will give it the same name as one of the files you backed up. Download your WordPress website backup and save it it your computer in a safe place.
Step 2: Backup your MySQL database using phpMyAdmin
Now that you have your WordPress files, like your themes and plugins, you will need to also backup your MySQL database. Without the database, your WordPress website will be pretty darn useless!
Inside of cPanel, locate and open the phpMyAdmin program.
Once phpMyAdmin loads, you will see a list of databases on the left hand side. Select the correct database for your live WordPress website to move to localhost.
Please Note: For most people, there will be only two databases listed. Your live website’s database and the default phpMyAdmin database (information_schema). When you select a WordPress database, you should see lots of tables listed inside like the ones shown below.
Create a complete backup of the WordPress database by going to the Export tab. Simply click the “Go” button and your database backup will be downloaded. This can take some time, depending on the size of your database. Save the database backup to the same location as your live website files.
Step 3: Install a localhost web server
In order to move a live WordPress website to a localhost server, you will need a localhost web server setup. Obviously. I recommend installing the XAMPP server package. You can download it from ApacheFriends.org.
If you need an in depth tutorial on how to install it for WordPress, you can check out my other article on how to install WordPress on a localhost server.
Step 4: Extract your WordPress website backup on the localhost server
With your localhost server up and running, browse over to the localhost website directory. If you use XAMPP like me, it should be located at C:\xampp\htdocs\
Create a new folder to house your local version of your live WordPress website. I’ll call mine HeyTuts.
Extract your live website backup inside of this folder. Once complete, you should see all the WordPress files directly inside of this folder. If not, then move them to this folder.
Now your localhost WordPress website should all be located inside of C:\xampp\htdocs\YOUR_FOLDER_NAME
Step 5: Import your MySQL database on your localhost server
Next, open phpMyAdmin on your localhost server. Usually, you can navigate to http://localhost/phpMyAdmin in your web browser.
When phpMyAdmin loads, you will see a list of all your current databases on the left hand side. If you have a brand new installation of XAMPP, the you should just have the default databases.
Above the list of databases, click the “New” button.
In the simple form, enter the name of your new database. I recommend naming something simple. Like your website name. I will use the name “heytuts“. When satisfied, click the “Create” button.
Afterwards, phpMyAdmin should auto select the new database for your. If not, then select the database from the left hand side.
Next, open the Import tab. Under the “File to import” section, browse and select your MySQL database backup from before. Then click the “Go” button at the bottom right. This will import your live website’s database into your localhost server. This can also take some time, so please be patient.
Step 6: Update the wp-options table in the localhost database
With your database successfully imported, we have to manually change some of the database records. Don’t worry. It is super simple.
Locate and open the wp-options table in phpMyAdmin. You must update the “siteurl” and “home” fields. (they should be at the top of the list already).
Click on the “Edit” button for each and change the “option_value” for each to be your new localhost website’s address. It should be http://localhost/YOUR_WORDPRESS_FOLDER.
Please note: If you are unsure, you can always navigate to your localhost web sever in the browser. Select the correct folder. Then just copy and paste the link.
Step 7: Update your wp-config.php file
With your new localhost database fully setup and configured, we need to update tell the WordPress configuration file how to connect to our localhost database.
Browse over to your localhost website’s folder and find the wp-config.php file. Open the file in your favorite code editor (I like VS Code). You can also use notepad if you don’t have a code editor.
Find the database connection settings in the wp-config.php file. They should be near the top. They will look like the lines highlighted above.
Update each of these settings for your localhost server:
- DB_NAME – the name of the database you created earlier
- DB_USER – “root”
- DB_PASSWORD – your phpMyAdmin account password (see below)
- DB_HOST – should not be set to “localhost”, if not already
Please note: If you just installed XAMPP and have not configured a secure phpMyAdmin password, then the default password is blank. Like “leave it empty” blank.
Step 8: Enjoy your WordPress website on your local server!
If you completed all the above steps, your website should now be fully functional on your localhost web server. So go test it out!
Navigate to your website by going to http://localhost/YOUR_FOLDER_NAME
Now you have successfully moved your live WordPress website to a localhost server! A great time to start trying new themes, creating custom themes, and testing new plugins. Go live your best WordPress life!