How to move a WordPress site to a different Server or URL

Moving a WordPress site from one server to another or to a different Web address (URL) may seem a daunting task and something to stay away from. The truth is that it is quite simple!

Last month I was asked to help moving a WordPress (WP) blog from one server to another and I thought I should share with the world how this can be done.

Performing this task requires 3 major steps:

1. Move the WordPress Source Code
2. Move the WordPress Database
3. Update the WordPress configuration

For the sake of this example I will provide the general instructions for a WordPress running on LAMP (Lunix, Apache, MySQL and PHP) environment with CPanel and I’ll assume that we want to move it from http://www.original-server.com/blog to http://www.destination-server.com/blog.

STEP 1 – Move the WordPress Source Code:

(Original server)- Download the WordPress source files:

1. On CPanel select “File Manager
2. Tick (check) the folder that contains the WordPress blog source files (ex: blog)
3. Select “Compress” from the menu
4. Select “Compress File(s)
5. Tick (check) the zip file you’ve just created
6. Select “Download” from the menu and save the zip file locally
7. Once the download is finished delete the zip file from the server

(Destination Server) – Upload the WordPress source code:

1. On CPanel select “File Manager
2. Select the “Upload” option
3. Locate and select the zip file that contains the WordPress source code you’ve copied into your PC.
4. Upload your file into the new server
5. Select the zip file
6. Select “Extract” from menu
7. Delete Zip file from server

Note: Beware! When you unzip the file if a directory already exists with the same name its content will be replaced!

STEP 2 – Move the WordPress Database:

(Original Server) – Export WordPress Database:

1. On CPanel select option “phpMyAdmin” (MySQL Databases)
2. Select the WordPress Database that you want to export (ex: wp01)
2. Select “Export
3. Make sure all the Tables are selected
4. Leave all the default options ticked
5. Make sure to download as an SQL file
6. Check “Save as File
7. Click “Go” and save it locally

Note: In addition you may also select “zipped” or “gzipped” to compress your database when downloading it.

(Destination Server) – Create new Database:

1. On CPanel select “MySQL Databases
2. Create a new DB for the blog (ex: wp01) and if possible with the same name as it had originally
3. Create a new user for the blog if possible with the same name as originally
4. Associate the new user with the WordPress Database you’ve just created and all privileges to it.

(Locally) – Update WordPress MySQL database:

1. Edit the WordPress SQL database you’ve downloaded from the original server.
2. If the web address URL has changed:

  • replace all references of the old URL with the new URL
  • note that if on the new server you’re using a different directory, this needs to change too.

3. If the email addresses have changed, replace them with the new addresses.
4. Save your changes.

(Destination server) – Upload WordPress Database:

1. On CPanel, select “phpMyAdmin” (MySQL Databases)
2. Select the WordPress Database
3. Select the “Import” option
4. Locate and select the WordPress SQL Database you have saved locally.
5. Import file

STEP 3 – Update the WordPress configuration:

(Destination Server) – Update config file:

1. On Cpanel select “File Manager
2. Locate and edit WordPress configuration file “wp-config.php
3. Update WP DB name with the new WordPress Database name:   define(‘DB_NAME’, ‘database_name_goes_here’);
4. Update user name: define(‘DB_USER’, ‘user_name_goes_here’);
5. Update Database password: define(‘DB_PASSWORD’, ‘password_goes_here’);
6. Update hostname (if required): define(‘DB_HOST’, ‘hostname_goes_here’);
7. Save your changes

STEP 4 – Testing:

1. Simply test your blog to make sure that all the functionalities are available