BLOG

WordPress Migration. How to move a website to a new server.

by | Feb 21, 2020 | Tutorials, Wordpress

This tutorial will show you how to migrate a WordPress website from one hosting service to another. Many people wonder why can’t they just copy the files from their current hosting server and save them into the new server?

Unfortunately it is not so straight forward. There is more to it. The whole process of migrating a WordPress website involves more than simply copying and saving the directory and file structure that stores WordPress’ core files, themes, plugins and everything you uploaded to your website.

The steps can be described into a few words: you have to export the database and import it into the new host, move your files to the new host and configure it. Each of these steps branch out in several other steps that must be performed in a certain order, otherwise the website will not work properly or you will see what’s called “the white screen of death”.

So let’s get started.

Steps to migrate a WordPress website

  1. Back up your WordPress website files
  2. Export the database
  3. Create a database on the new host
  4. Edit wp-config.php
  5. Import your database
  6. Upload all WordPress Files to the new host
  7. Search and replace
  8. Point the domain to the new host

 

1. Back up your WordPress website files

Connect to your website host using an FTP program (such as Filezilla) and copy all files under your website’s directory (including the .htaccess file) to a folder on your local computer.

2. Export the database

Login to your current web server cPanel and open the phpMyAdmin application. Select your website’s database (if you have more than one in that server) and click on “Export” to download a “SQL” file to your computer.

3. Create a database on the new host

The new host needs to have a database that will be used to import the “SQL” data into. To create a new database, log into the cPanel and choose the MySQL Databases application. Create a new database and a new MySQL user with a secure password. Then add this new user to the database. Make sure to grant this new user all privileges.

4. Edit wp-config.php

The wp-config.php file controls the access between all WordPress files and your database. You need to edit the wp-config.php file that you just copied into your computer (in step 1). Locate the following lines on the file:

  1. define(‘DB_NAME’, ‘db_name’);
  2. define(‘DB_USER’, ‘db_user’);
  3. define(‘DB_PASSWORD’, ‘db_pass’);

Replace ‘db_name’ with the database name you just created, ‘db_user’ with the user and ‘db_pass’ with the password.

5. Import your database

Go to cPanel on your new host, launch phpMyAdmin, select the database you just created and select “Import”. Click on the “Choose File” button and select the “SQL” file that you downloaded in step 2.

6. Upload all WordPress files to the new host

Connect to your new website host using an FTP program (such as Filezilla) and upload all files that you downloaded to your local computer in step 1, including the wp-config.php file that you edited in step 4.

7. Search and replace

If you are moving to a different domain (which is always the case when you are moving from a development site into a live site) you will need to search and replace every instance in the database that points to the previous URL. This can be done using a script or the find and replace tool of a code editor.

8. Point the domain to the new host

Log into you domain registrar account and point the A record to the new server’s IP address. This change can take up to 48 ours to propagate (some registrars are faster and can take less than one hour). Once the change has fully propagated the website will be accessible from the new host.

Share This

Share This

Share this post with your friends!