Migrating a website from a local server to a live server is not easy. Migrating the database is the difficult part of the process. This is mainly because of the large amount of time it takes to dump the data and load it into the new database. Other factors that make up the migration process are the security of the database and the content. In this blog, we will be looking at how we can migrate a WordPress site from a local server to a live server in three simple yet different ways.
The First Step Towards Migrating Your WordPress Site
The bulk of WordPress development takes place in the local development environment (A.K.A. localhost). Developers have the option of using XAMPP (Windows) or MAMP (Mac) to build WordPress-powered projects.
Once they are satisfied that everything is working correctly, it is time to migrate the WordPress site from localhost to the live server.
Working at localhost is a great idea that lets developers work on improving the codebase without affecting the live website. This is very important for WordPress-powered corporate portals and e-commerce stores where downtime is a serious challenge.
Developing at localhost allows the dev team to continue to tinker with the code while the business continues without any downtime. Once the codebase has been thoroughly tested, moving it to the live server is a simple step.
In this guide, I will explain the following three popular ways of transferring a WordPress site to a live hosting server-
- Use the built-in WordPress Export Tool
- Manually migrate the WordPress site to the live server
- Use a WordPress plugin
Before You Begin
For the purpose of this guide, I am assuming that you have a localhost environment (complete with FTP and database access) set up and the website has been developed and ready for the move. To illustrate the process, I am using Cloudways, a managed web hosting for WordPress.
On my WordPress website installed at the localhost, I have added the following items-
- One Post
- One Page
- One User
- Active Plugin: Classic Editor
- Active Theme: Twenty Fifteen
I will start with the built-in WordPress export feature.
1. Use the Built-in WordPress Export Tool
- Posts
- Pages
- Comments
- Custom fields
- Terms
- Navigation menus
- Custom posts
To use the WordPress export feature, you need to export the data from localhost and import it to the live server.
Export Data From the Localhost
Log in to your localhost WordPress site and navigate to Tools → Export.
You will be asked which data items you want to export. In my case, I have opted for exporting the complete data. Thus, I selected All content, and then click the Download Export File button.
Downloading the XML file could take time, depending on the size of the WordPress site.
Import Data at the Live Website
Once the XML file has been downloaded, log in to your live WordPress website, and navigate to the Tools → Import.
You will see a list of options for importing the data. Scroll down a bit and look for WordPress. Click the Install Now button below and then Run Importer.
On the next screen, you will be asked to choose an XML file. Click Choose File button and navigate to the XML file you downloaded in the previous step. This will upload the XML file to the live server.
Now Assign Authors and Import Attachments. If you want to import attachments as well, check the box with the caption Download and import file attachments.
Importing the data takes time depending upon the size of the data at the localhost. This is the simplest and quickest way of moving limited data from localhost to a live server.
2. Manually Migrate a WordPress Site to The Live Server
The problem with using the WordPress Export Tool is that the plugins, themes, users, etc. are not moved from the localhost to the server. This happens due to the limitations of the process that only focuses on the posts, pages, and comments.
In order to move a WordPress site from localhost to a live server without any loss of data, you have the option of manually transferring files and databases to the live server.
Since I am using XAMPP as my local development environment, the WordPress files are located in the /xampp/htdocs/wp/ folder. Since I am looking for moving the entire website, I need to upload all the files and folders in this folder to the live server.
There are two ways of transferring the contents of the wp folder to the live server. You can either drag and drop everything or create a zip file that could be uploaded directly to the server. Of these two, the unzip method is really fast.
If you opt for the zip method, note that you need a way of unzipping the file at the live server. In many cases, there is an unzip script or a Terminal available at the server.
In this example, I will use the zip method.
Navigate into the /wp/ folder, and zip all files and folders.
Once done, simply upload it to the live server.
For this, you can use any FTP client. I prefer FileZilla as my FTP client.
Launch your FTP client and enter your FTP credentials including Host, Username, Password, and Port (your hosting provider can provide all the information). In my case, Cloudways provides master credentials as my FTP credentials.
Now go to the live server’s WordPress installation and delete everything. Next, I will upload the zipped file.
Unzip Files Using Terminal
You may need a Terminal/Command Line Interface (CLI) to run the Unzip command.
Log in to the cloud server using PuTTY and navigate to the WordPress application (csubeazedd is the folder name of my WordPress site). If you are hosted on Cloudways, here’s how you can find your folder name.
Here are the step-by-step commands for unzipping files at the live server. Firstly, connect with the server using PuTTY.
Use master credentials on the next screen.
Within a few seconds, the zip will be extracted and visible in FileZilla.
Unzip WordPress Files Using a Script
If you are not familiar with the Terminal, do not worry!
GitHub hosts a script that can help you out!
Create a new unzipper.php file in the folder where the zip file has been uploaded on the live server. Next, paste the entire code from unzipper.php into the file.
Navigate to this file using the URL example.com/unzipper.php in the address bar. Cloudways provides a WordPress staging environment and offers temporary URLs ( in my case, the URL looks something like this):
http://wordpress-192114-825599.cloudwaysapps.com/unzipper.php
You can see the zip file. Just click the Unzip Archive button and you are done!
Export Database From Localhost
Next, you need to export the database from localhost to the live server. Navigate to the database manager:
localhost/phpmyadmin
Get into the WordPress table and export the database.
The database file that you need to import will now be downloaded.
Import Database to the Live Server
Generally, hosting providers use phpMyAdmin as the database manager. Your WordPress hosting provider might have a different database manager. However, the following steps are valid regardless of the database manager.
Log in to the database manager using the database credentials.
Navigate to the existing WordPress database. Generally, it should be empty. However, if this is not the case, delete the database using the following SQL command.
DROP DATABASE name
Next, create a new database using the following SQL command:
CREATE DATABASE name;
(replace “name” with your previous database name)
Now, click Import and choose the previously download .sql file.
The upload process may take some time depending on the size of the database file.
Next, edit the wp-config file on the live server to add the new database credentials.
Update WordPress Home and Site URL in The Database
The last step is to update the Home and site URL. For this, navigate to the wp_options table and look for the site URL and home.
Replace the values with your domain name.
If the localhost URLs still exist, use the Velvet Blues plugin to replace localhost URLs with the actual domain name.
You have successfully migrated a WordPress site from localhost to a live server.
3. Use a WordPress Plugin
If you are uncomfortable with the manual migration, you can use a WordPress migrator plugin such as Duplicator.
Log in to the localhost WordPress dashboard, navigate to Plugins → Add New, search for Duplicator, Install and activate the plugin.
From the left pane, navigate to Duplicator → Packages and Create New package.
Click on the Next button to scan the WordPress website.
Once done, you will see the following screen. Click Build. If there is an error, resolve it first to avoid any problems later on.
It will take some time to build the package.
Download both the files, Installer, and Archive generated by the Duplicator plugin.
Upload both files to the live server via an FTP client. Make sure the installed WordPress site is blank. If not, first delete all files and folders before uploading the files.
Head over to the installer.php via the address bar. In my case the URL is:
https://wordpress-192114-825599.cloudwaysapps.com/installer.php
The Duplicator will start the process of extracting the archive file and the process has the following four steps:
In the first step: Deployment, the two environments, localhost, and the live server are compared.
The second step relates to the database of the live server. For this, make sure the database is blank. The duplicator offers two options, either delete all existing data of the database or create a new database. Choose whatever option suits you.
The third step is about Data Replacement in which you need to enter the live website URL. Generally, the URL is fetched automatically. If not, edit it accordingly.
Finally, Duplicator offers to test the newly migrated WordPress from localhost to server. Follow the sequence as presented on the screen (Save Permalinks, Test Site, Security Cleanup, and Show Report).
Wrapping Up!
Migrating WordPress sites from local servers to live server is a complex task. There are numerous factors that need to be taken care of while shifting WP site from local server to live server like updating the new site URL in existing website Google Search Console, Search Engine Optimization, Pure HTML Website, Broken Links, Duplicate Content, etc.
By following one of the above methods, you can move WordPress from localhost to a live server without any hassle. In case of issues, you should get in touch with your hosting provider so that they can work out the specific issues and ensure a smooth migration.
Author Bio: Mustaasam Saleem is a WordPress Community Manager at Cloudways – A Managed WordPress Cloud Hosting Platform. When he is not working behind his computer screen, you can find him playing squash with his friends, or defending in Football and listening to music.
Thanks for posting this wonderful article. Every step has been mentioned very clearly. It is really worth it for us. I have used both method manual as well as plugin both seem easy.