How to move WordPress site to a new server or a new domain without downtime?

Here is a Step by step procedure to move a WordPress site from one server to another server or from localhost to server. You can also move the complete website setup from one domain name to another.

If you have hosted your website on a dedicated server or cloud server and don’t have a cPanel and PHPMyAdmin access, then click here to read How to move WordPress site to a new server or a new domain using SSH?

Assumptions

Server 1: Current server where WordPress is set up. This can be your local host also.
Server 2: The server where you want to move the website.

Follow the below steps.

1. Server 1: Export database

We can use a simple plugin to export the WordPress database. Login to the WordPress control panel of server1 and install the plugin “WP Migrate DB

WP Migrate DB plugin

WP Migrate DB helps to export the WordPress database, does a find and replace on URLs and file paths, and then allows you to save it to your computer for free of cost.

Once the installation is completed, open Tools -> WP Migrate -> MIGRATE -> Export database.

Here we have to update the domain name and website file path.

To move the website from one domain name to another or from localhost to the actual domain name, you need to fill Current address and new address. If there is no change in the domain name, then just leave it blank.

File-path is the complete file path of your server. You can get this file path on the cPanel. If you don’t know the full path, you can ignore this.

Click Export Database to export the database. Download and keep it.

2. Server 1: Download the website files

Download complete website files from server1 using FTP or file manager. As there are multiple files, it is better to zip the files and download them as a single file. Login to cPanel and click on File Manager.

cPanel File Manager

Go to the public_html folder. Select all the files inside and click on the compress option on the right-click menu. Give a name and save it in the public_html folder. Now download the zip file.

Alternatively, you can download the files using any FTP application.

Now we have taken the complete back of WordPress files and database.

3. Server 2: Import Database

Database section in cPanel
  • Login to Server 2 cPanel
  • Create a new database
    • Open MySQL Databases
    • Create a new MySQL database and note down the created database name
    • Create a new MySQL user
    • Add User To Database: Select the created user and database and click add. Provide all the permissions.
  • Import the database
    • Open phpMyAdmin
    • Select the database on the left-hand side
    • Click on Import
    • Chose file: Select the exported database dump downloaded from server 1
    • Click on the ‘Go’ button.
    • Once the import is done, there will be a success message.

4. Server 2: Upload the website files

Upload the downloaded WordPress files zip file to the public_html folder of Server 2. You can upload using the FTP application or using File manager.

Login to server 2 cPanel and go to File Manager. Select the public_html folder. Upload the WordPress files zip file. Once the upload is done, unzip the files into the public_html folder.

Edit the wp-config.php file and update the database and user details which you have created and noted down.

/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );

/** Database username */
define( 'DB_USER', 'username_here' );

/** Database password */
define( 'DB_PASSWORD', 'password_here' );

/** Database hostname */
define( 'DB_HOST', 'localhost' );

5. Update the DNS records

Now you have moved the database and all the website files from one server to another. Now is the time to point the domain to the new server.

Login to the domain control panel and go to DNS or name server settings. Point the DNS of your domain name to the new hosting server. Usually, it will take 12-24 hours to update the records.

6. Browse the website and enjoy!

You are done with all the tasks. Open the URL on the browser and check if the website opens properly. Still, your domain may point to the old server and open the website properly. To check whether the website loaded from the old server or the new server, you use the ping command on the command prompt and check the IP. You can also rename the index.php file of the old server and check if the website loads properly.

Just drop a comment if you get any problems while moving the website. I will be happy to assist you.

Ranjith Kadamboor
Ranjith Kadamboor

Programmer with 15+ years of broad experience in Software Design and Development, Interested in Blockchain and Crypto.

4 thoughts on “How to move WordPress site to a new server or a new domain without downtime?

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in