Updated on Jan 16, 2020
In this tutorial, we will show you how to migrate a WordPress website to a new host safely. In general, the task is easy and if you have been using WordPress for a while, you should have no problem performing it correctly. There are three main methods to do that – with the Duplicator plugin, manually via FTP, and by using the WordPress Command Line (WP-CLI).
Our goal with this guide is to help you avoid every possible mishap while easily moving your WordPress website from one web host to another.
Keep in mind that the guide is not entirely beginner-friendly. It’s for users that prefer to do things on their own (do-it-yourself style). If you don’t have the time for that, you can always request it from our technical support team via a support ticket. We will gladly move your WordPress site to the FastComet servers.
Now, let’s have a look at what we will cover:
The first step you take with projects of this type should always be backing up your site completely. It’s not only good practice, but also a required one before any major changes, and moving an entire WordPress site counts as such.
While there are more than enough plugins to help you by backing up the whole website for you, for this post, we will cover the manual method. We will use an FTP client like FileZilla. Connect to your current web host and copy all files (including the hidden .htaccess
file) in your website directory to your local computer.
To see hidden files in FileZilla, on the top menu bar, go to Server → Force Showing Hidden Files:
Depending on the size of your site, the backing up process may vary.
There are multiple reasons to decide to move your WordPress site to a new hosting provider:
After you have purchased a hosting package with your new web host, don’t rush into installing WordPress. You are going to do that, of course, but a bit later on.
Keep in mind that our migration experts provide fast managed transfers on all plans, including moving of all your files, databases and emails. If you wish to become a FastComet client (or you already are) and transfer your WordPress site to our servers—feel free to submit a support ticket.
Also, if your previous host was cPanel based, you can migrate your cPanel account with FastComet with no data losses and zero downtime.
There are various excellent WordPress plugins for migration, all of which would take care of each necessary step of the moving process, ensuring that your website gets migrated swiftly. For this guide, we will be using the Duplicator plugin. We start by adding and activating Duplicator on the WordPress site that needs moving.
Add the plugin from your WordPress Dashboard, navigate to Plugins → Add New:
Duplicator is one of the top plugins for moving a WordPress site, and it’s also free to use. You can use the plugin for moving your WordPress website to another domain name, too. However, this post will teach you how to use Duplicator for your WordPress site migration from one web host to another without any downtime.
Once you’ve installed and activated the plugin:
After you have downloaded both the installer and archive files, the following step is uploading those files to your new web host. You need to connect to your new hosting provider via an FTP client like FileZilla, or by using the cPanel File Manager.
Typically, you’d be entering your site’s domain name as a host when using an FTP client.
In this case, though, your domain name is not yet pointing to your new web host, so you need to connect to the FTP client by entering your new server’s IP address hostname. This information can be found from the cPanel dashboard of your new web host:
While in the FTP client, upload both the archive .zip and the installer.php files into your site’s root directory.
Typically, the directory that you are looking for should be the /username/public_html/
folder. It stores all HTML files and other web content, therefore each of your site pages loads from the public_html
directory.
You do that if the site you are moving will be the primary site for the domain. If not, you will need to set up an addon slot and upload the files on the addon domain folder.
Some web hosts preinstall WordPress as a part of their services. If you have this type of WordPress installment, check to see if it’s active. Once you find out it’s not, you can delete it before you continue.
Now upload both the archive and the installer files to the root directory of your site.
Once you have uploaded both these files to your new host, go ahead and access the installer.php
file in any browser.
Normally, you can access the installer file using a URL like:
http://www.example.com/installer.php
However, if you try this URL, it will take you to your old host, resulting in a 404 error. That happens because your domain name still points to your old web host.
If you change your domain nameservers and point it to the new hosting provider, your visitors are going to see a broken site during its migration. Since we promised no downtime, we will show you how to access your new website temporarily on your computer.
You do this with a hosts
file on your computer. This hosts
file is to map domain names to particular IP addresses. Simply said, the file helps you trick your computer that the WordPress site is moved, even when it’s not.
Next, we will go over how you can use the ‘hosts’ file to include an entry for your domain name, making it point to your new web host.
Such changes are going to allow you access to the files on your new web host using your domain name, while all users will still access your site from your old host. This guarantees 0% downtime.
Now, the first thing to do is finding the IP address of your new hosting server. To do this, log into your cPanel dashboard, and then click on the link that says ‘expand stats’ in your left-hand sidebar. When using shared hosting, the address of your server will be listed as Shared IP Address.
Next, Windows users have to go to Programs → All Programs → Accessories, right-click on Notepad and select the option Run as Administrator:
A Windows UAC prompt will appear, where you need to click on Yes to launch Notepad with administrator privileges:
On the Notepad screen, go to File → Open and then navigate to C:\Windows\System32\drivers\etc. From thеre, select the hosts
file and open it (via Notepad).
When using Mac, you need to open the Terminal app. To edit the hosts
file there, enter the following command:
sudo nano /private/etc/hosts
For both Windows and Mac users, you have to enter the IP address (the one you have copied from the cPanel), and then enter your domain name:
192.168.1.22 www.example.com
Make sure that you replace the IP address with the one you have copied from cPanel and example.com with your own domain name.
Once you have finished, don’t forget to save all the changes:
Now you can use your domain name on your computer to access your files on the new web host.
Note:
Do not forget that after you finalize the migration, you need to undo all the changes you have just made.
Before running the installer on the new host, you have to create a MySQL database on the new hosting account. If you’ve already created a MySQL database, then you can skip this step and jump to the next one.
Your database is ready to be used with WordPress now. Make sure that you create a note of the database name, username, and password. The next step will require that information.
We are now ready to run the installer:
http://www.example.com/installer.php
Of course, you will need to replace example.com with the name of your website;
Now you can go ahead and log into your WordPress site on the new host and make sure everything is working correctly.
You can start exporting your database while the backup via FTP is in process. Exporting your database is quite simple and requires only a few steps:
In that case, the default settings (Quick export and SQL format) will suffice for our goal.
Once both the database export and the FTP transfer of your files have completed, you will be ready to proceed to the next stage.
Before starting with the migration to your new host, you have to create the environment for your WordPress installation. For that, you will need a database into which to import your SQL data.
Login to the new web host using the credentials they provided for you upon sign up. Once you’re in, connect to the cPanel software. Since FastComet works with the MySQL Database application, we will be using it for this guide.
There are a few easy steps to create a new database, which are:
Don’t forget to write down your database name and the new MySQL username and password because you will need them quite soon.
You can begin uploading your website’s files to the new host:
Do not delete the backup from your local machine even after the upload finishes. Those files are still needed until the whole migration process is completed.
Browse your WordPress site’s folder on the new web host and find the wp-config.php
file. This file controls the access between WordPress and your database. Since you already made a copy of the file on your computer, which is in case something goes wrong, you don't need to create another.
Now, you need to open the wp-config.php
file and make the following changes:
Locate the line:
define('DB_NAME', 'db_name');
The db_name portion of this line will currently be set to the database name of your previous web host. Change this to the name of the new database that you’ve just created.
Below the line with the database name, you will find:
define('DB_USER', 'db_user');
Here you need to change the db_user part from the username of your previous host and make it match the new username you’ve just created.
What’s left is editing the third line:
define('DB_PASSWORD', 'db_pass');
Again, as with the other lines, change the db_pass part of this line, using your new secure password for your MySQL user.
That’s it! Save the wp-config.php
file and close it.
Since you have a new database, you can begin with the importing process:
Keep note: There is a chance that your internet connection times out if the database that you are importing is too large. In that case, the import can be done via SSH and you should best contact your new web host’s technical support team.
That’s all. The database upload will now begin. The time the import takes is based on the size of your database. You should get a message once the process is complete.
If you are moving your WordPress site to a different domain, you should read what this step contains. Otherwise, you can skip it, because you don’t need to update your website, making it point to a different domain.
A common issue when moving a site is that there are links to posts on it or images that point directly to a URL on the previous server. Those links will break if the WordPress site is moved to a new domain.
If you want a swift search for all instances where your old domain name is included and replace it with the new one, we suggest using the Search Replace DB script on GitHub. It has everything explained and allows you to do what you need quickly.
However, for security reasons, make sure that you delete this script when the job is done. Also, do not place the script in your root domain, but rather create a temporary folder for it.
WP-CLI, similarly to SSH, is a command line interface. The main difference is that WP-CLI is specific only to WordPress. This tool is simple yet powerful because it allows the user to operate WordPress in the same manner as with the frontend. Many WordPress developers prefer using the WP-CLI, precisely because of its flexibility.
WP-CLI can be used for:
While all of the above can be done via the web interface, it is still a preferred way of performing tasks without distractions.
To make sure that WP-CLI is installed, open your SSH (FastComet has a custom SSH port - 17177) and type the following command:
wp --info
When you do not have WP-CLI installed, the following error is going to appear:
-bash: wp: command not found
That can be fixed by installing the WP-CLI. Run the following command in the SSH terminal of your old server. cd back to the opt folder by going all the way to the root location. Just keep run the ‘cd /’ to get there.
Install WP-CLI with the following command:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
This should install the WP-CLI. Next, confirm this typing the wp –info
command.
After that, change the file’s permissions to make it executable:
chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp
Then, go back to the main WordPress folder and run the following command to see the version of the WordPress installation:
wp core version --allow-root
All good now! Let’s go ahead and take the backup of our WordPress site using WP-CLI.
Creating a backup using WP-CLI is quite similar to the SSH-based process:
zip -r wordpress.zip wordpress
mv wordpress.zip
The database can be backed up easily:
mysql -u ewscfaavrd -p ewscfaavrd < site.bak.sql
This is to create the backup file that can be exported easily to the FastComet server using the Terminal.
The command line for exporting the database is:
wp db export
wget http://[serverIP]/wordpress.zip
This command will fetch the zipped folder from your old server through a URL.
Note:
There is a slight chance that the wget command does not work. If that happens, you can use the cPanel File Manager and upload the file.
unzip wordpress.zip
mv * ../
There you go! I have successfully fetched the zipped folder and moved the WordPress site to the new host.
We have covered this subject once, so the rule applies here as well—if you are not moving your WordPress site to a different domain, you can skip reading this current step.
If you are migrating to a new/different domain, you will need to replace the URLs pointed to your old domain through a simple process.
In the Terminal, run the following command:
wp search-replace "http://old-url.com" "https://new-url.com"
Of course, ‘old-url’ stands for your old domain name, and ‘new-url’ stands for the one that you’re moving your website to.
This command will search for all the URLs with your old domain name and then replace them with the new URL provided that you provide.
If you followed our guide without stumbling upon any difficulties, you should be able to access your migrated WordPress website without issues.
Keep note:
There is always a chance that the migration does not complete properly. In such cases, don’t hesitate to contact the FastComet technical support. You can do that by opening a support ticket.
If everything feels okay after testing, you can go ahead and clean up by deleting all the backups that you had to create. Of course, this is optional, and we actually recommend that you keep the backup, especially if you have plenty of space on your local computer. You cannot be too careful.
In fact, there are two things to do here.
Before being able to use your site on the new host, you will have to reconfigure your domain’s DNS settings. Currently, they are set to point to your previous host. What you have to do is point the correct records to the new server IP address.
The process is dependent on where you have registered your domain. Your domain registrar should have all the details you need to make the change.
DNS changes could take up to 48 hours to fully propagate, thus you should do this when you expect lower traffic levels. During the 48-hour window, it’s best to avoid making changes to your WordPress website as you could be changing the old version of your site.
After the expiration of those 48 hours, you should be accessing the new web host when going to your website. This is when you can connect back to your old host and delete the files and database.
As you can see for yourself, when explained thoroughly, moving your WordPress site to a new host is not that complicated. Choose one of the three methods we have covered—follow the steps and everything should be just fine.
The success of the whole process comes down to just being careful when executing each step, without skipping them. Even if something goes wrong, you will have the backup to fix it and all will be good. Once again, if you need assistance with moving your WordPress site to the FastComet servers—you can always count on our technical support to help you. Our experts work 24/7 for your convenience.
We hope you find this article useful. Discover more about FastCloud - the top-rated Hosting Solutions for personal and small business websites in four consecutive years by the HostAdvice Community!