How To Move WordPress To Another Web Host – WPQuickies

Sometimes you need to move your WordPress website to another web hosting service. Today I’ll show you several ways to move your WordPress website.

Reasons To Move WP To Another Web Host

You may need to move your WordPress website to another hosting provider for many reasons.

  • Cost
  • Bad experience with support
  • Great pricing deal (Black Friday/Cyber Monday)
  • Site performance

A List Of Things To Do

When moving your WordPress installation, there are a few things you need to pop onto your to-do list.

  • You’ll need to move your files -that could include the WordPress core app, plugins, theme and your uploads folder contents.
  • WordPress stores post content in a database, so you’ll need to move the contents of your existing database to one on the new web host.
  • Your new web host may not have its database server at the exact location as your previous host, so you may have to reconfigure WordPress to point to the new DB server.
  • If you change your domain name and move your WordPress site simultaneously, you’ll need to rename the URLs in the database to point to the new domain name.

Manually Moving Files

The process for manually moving files from one server to another is to create an archive.  That could be a single zip, gzip or tar file that contains the files you want to move.

Remember that files are spread across different locations.

You’ll at least want to move files from the plugins, themes and uploads folders.

Using File Manager

Most web hosting companies will use cPanel or Plesk as their account management system.  File Manager is a standard app across both systems.

File Manager app on cPanel or Plesk

You can create archives by right-clicking on any folder and giving the archive a name.

Once the archive is created, you can right-click on the archive and download the file to your local machine.

Log into File Manager on your new web host and upload the archive to the same location, then right-click and unpack the archive.

The process is simple, but downloading and uploading could take a while, depending on your large archive file.

Manually Using FTP, FTPS or SFTP

If you want to move files manually or use another client, you should know the different protocols to transfer files between servers.

FTP = File Transfer Protocol.

It uses port 21 or 22 on the server – you’ll have to ensure you have the correct port number in your transfer client.

Pro: Has been around since the dawn of the internet and is supported by all web hosts.

Con: No encryption, so if transferring sensitive files, they could be stolen during transmission.

Con: a bit slow as it uses two data streams – one for data and one for control

You should try to avoid using FTP.

FTPS = Secure FTP

It uses port 990

Pro: same as FTP  – widely supported by web hosts.

Pro: uses SSL encryption.

Con: same as FTP – a bit slow

SFTP = SSH File Transfer Protocol

It uses Port 22.

Pro: Secure – uses SSH (Secure Shell) keys for authentication

Pro: Only one data stream for both data and control = much faster uploads and downloads

Con: difficult for beginners to create and manage the public and private SSH keys for authentication

File Transfer Clients

Here are three widely used file transfer clients.

WinSCP – Free and has a global password to protect your accounts.

PuTTY – Free – SSH client – command line interface

PHPStorm – Integrated development environment (IDE) – this is the client I use when developing for WordPress, and it has a built-in file transfer client that supports FTP, FTPS and SFTP.

Moving the Database

Before you can move the database, you need to ask yourself the following question:

“Am I moving the site to a new domain or folder structure?”

If you are, you need to rename the URLs stored in the database. Otherwise, they will no longer point to the correct location after the move.

e.g.

olddomain.com  → newdomain.com

olddomain.com/wordpress  → newdomain.com

olddomain.com → newdomain.com/blog

How WordPress Stores URLs

WordPress stores absolute URLs in the database for reasons of long-term data integrity.

Absolute URL Example

An absolute URL includes the protocol and top-level domain name at the URL’s start.

https://wilbrown.com/free-business-resources/

Relative URL Example

A relative URL has no protocol or top-level domain name at the URL’s start – the web server has to work out what they are.

/free-business-resources/

Also, WordPress allows a post to be viewed in multiple ways, directly, taxonomy, RSS feed etc. – relative URLs would not allow this.

Because absolute URLs are stored in the database, if you change the domain or folder structure on the new web host, the links need to be renamed to reflect the change.

Serialised Data in the DB

WordPress stores some data (arrays) as serialised data in the database.

Serialised Data Example: {s:21:”https://wilbrown.com/”}

In the above example, the s:21 part tells WordPress that the next string has 21 characters.  This improves data integrity.

If you were to simply download the database SQL file and perform a manual text-based search and replace of the domain name, the number of characters would mismatch the length of the string, and WordPress would flag this as bad data.

This will result in invalid URLs and settings, and your newly moved WordPress site will not work correctly. You’ll lose Theme Options, Customizer settings, Menus and Menu location links and all widgets and widget areas as a minimum.

WP Migrate DB Plugin: Free and Pro

One of the best plugins to move your database data is WP Migrate DB.

The free version allows you to rename URLs in serialised data and save the DB file as SQL or SQL.gz – generally, you want to save your SQL as a .gz GZIP compressed archive to squash the file size down.  It makes the file transfer a lot quicker.

The paid (pro) version WP Migrate DB Pro, allows you to pull and push the database data from your old host to your new host without downloading it to your local machine and uploading it manually to the new server.

It also checks the new host for any issues, and you can select only specific database tables to transfer – handy if your WP installation is old and has a heap of unwanted tables.

The pro version allows you to synchronize your media files to the new web host.

The free plugin interface is super easy – just enter the current and new URL, leave the defaults, and click on “go” to save the file to your local machine.

WP Migrate DB

If you are using the free WP Migrate DB plugin to download the database SQL.gz file to your local machine, you will need to manually load this file into the database server at your new web host.

Both cPanel and Plesk come with the phpMyAdmin app that allows you to import a .sql or .sql.gz file into your new database.

phpMyAdmin cPanel and Plesk app

SQL File Too Big?

If your .sql file is too big, you should consider generating the compressed sql.gz file instead – this should solve any timeout problems you may get with uploading the data file with phpMyAdmin.

If your sql.gz file is still too large and is causing timeout issues when being imported to phpMyAdmin, your only real alternatives are to:

  1. Raise a support ticket with your new web host, send them the file and ask them to import it
  2. Use a Secure Shell (SSH) command line to import the file – there are no timeout issues using the command line.

If you are using SSH and the command line to import the file into the MySQL database, you will need to first transfer the file to the new server, then enter the following CLI commands.

> mysql -u username -p database_name < file.sql

For .sql.gz use:
> zcat file.sql.gz | mysql -u username -p database_name

Check wp-config.php DB Server Location

The last thing to check is your WordPress configuration file wp-config.php.

When moving to a new web host, ask for the database name, username, password and host.

They are defined in the wp-config.php file using the following lines.

define( 'DB_NAME', 'wpdb1');
define( 'DB_USER', 'bob');
define( 'DB_PASSWORD', 'Gt8%6jKlMvc43');
define( 'DB_HOST', 'localhost');

Other WP Migration Plugins & Tools

If you don’t want to manually move your WordPress site, there are many alternative migration plugins available.  Here are the top 6.

  • XCloner
  • Backup Buddy
  • Updraft Plus
  • Duplicator Pro
  • Migrate Guru
  • Jetpack
  • WP-ClI

Also, if you are planning to use the SSH command line interface, check out WP-CLI – it’s the command line interface for WordPress and has a heap of tools to help administer your WordPress site.

Finally, Watch Out For

When you move your WordPress website, you’ll need to also watch out for the following:

.htaccess file

This file may be hidden in File Manager.  It’s used for caching and redirects.  It may be worthwhile checking to see if you have a .htaccess file on your old web host and check its contents.

Caching plugins

Caching plugins can also use the .htaccess file and may be redirected to a cache of files you may not have moved over.  Sometimes it’s best to disable a cache plugin when you move to a new host.  Enable it after everything is working OK and clear the cache.

Security Plugins

Similarly to caching, security plugins can change your server environment.  The best practice is to disable the security plugin on the new web host and re-enable it once the site is working.  Check all settings to make sure they are still enabled and working correctly.

Summary

That’s my comprehensive guide to moving your WordPress site to another web host.

Do you still have questions about moving WordPress to a new web host?

Ask in the comments below.

#WPQuickies

Join me every Thursday at 1 pm Sydney time for some more WPQuickies – WordPress tips and tricks in thirty minutes or less.

Broadcasting live on YouTube and Facebook.

Suggest a #WPQuickies Topic

If you have a WordPress topic you want to see explained in 30 mins or under, fill out the form below.

https://forms.gle/mMWCNd3L2cyDFBA57

Watch Previous WPQuickies

Was this article helpful?
YesNo

One Response

  1. I’ve recently started a web site, the information you provide on this website has helped me tremendously. Thanks for all of your time & work.