Guide: Migrate Your Wordpress Site From One Server to Another

Wordpress migration illustration
Anda berbicara Bahasa Indonesia? Baca artikel terjemahannya di sini!

P.S.: Please excuse some of the pictures. Currently, I'm testing a watermarking software. Watermarking is needed to prevent misuse of the pictures in this blog. Pictures will only be watermarked if I personally took or made them.

If you’re looking for an easy, no-nonsense blogging platform, Wordpress is still the way to go. It’s supported by many hosting companies, has solid community, thousands of plugins and themes, and regular updates. Installing it is also a breeze, with many hosting companies offer automatic, scripted installation for free. If you want an example, our sister blog, Technoverse, is based on Wordpress.

But, the problem with a lot of hosting platforms is that sometimes, we feel the urge to move. This urge can be caused by many things: cheaper rates, promotions, better and faster servers, etc. This move calls for migration, and for some people, it's a terrifying word.

Worry not, today I'm going to show you that Wordpress migration is not terrifying at all. I've already moved from one hosting to another for at least three times, either Technoverse or my other Wordpress projects. So yeah, the following method is already tried and tested.

Start with File Backup

The first step is to backup all the Wordpress files in your server. You can compress your whole site's directory then download it, or you can choose to download all your files using FTP (such as FileZilla or Cyberduck).

Believe me, compressing before downloading is much faster than using FTP... If you're into that sort of thing...
This can take a while, especially when your site is already large, and has a lot of media files.
Remember, all files must be downloaded. Otherwise, you'll risk breaking your site in the new server later.

Continue with Database Backup

In case you don't know, all your site configurations and posts are stored in the database, including data for your themes and plugins. So yeah, they work together. Excluding one from another will render your site useless.

You can backup your database (I'll refer to them as DB from now on) by accessing PHPMyAdmin on your hosting platform (or other web-based DB app your hosting platform uses). Identify your DB name, and export the database (yes, the whole database). This will give you a SQL file. You'll need to re-import this file in your new server.

Exporting your DB using PHPMyAdmin is fairly easy and straightforward.

Identifying your Site's DB

If you're not sure which DB your site uses, you can look at a file named wp-config.php. It's located in your site directory. You can't miss it.

The wp-config.php file is located on the outermost location inside your site directory.
Open that file, and you'll see the following line: define('DB_NAME', 'test-db');
On the example above, test-db is the DB name your site is using.

Let the Migration Begin!

Okay, so the backup is ready, and I assume your server is ready too. Let's start migrating, then.

Create Database in New Server

First, you'll need to create an empty DB for your migrated site. This may vary depending on your hosting platform, but be sure to remember the DB credentials:

The DB Wizard in cPanel will guide you step by step to set up your new DB.
  • DB host address (usually localhost)
  • DB name
  • DB username
  • DB password.

Update Your wp-config.php File

Now that you've created a new, empty DB, you need to tell your site to read from the new DB. Open the wp-config.php file, and make the necessary changes.

You should see a lot of this line: define('XXX', 'YYY'). Change the YYY (leave the quotes be) to your new configuration.

Most likely you'll only need to change four items:
  • DB_NAME, which is the name of your DB.
  • DB_USER, which is the username to access your DB.
  • DB_PASSWORD, which is the password to access your DB.
  • DB_HOST, which is the address to your DB. Usually localhost, but yours could be different.
Under most and normal circumstances, you'll only need to update the four lines above.

Upload the Files to Your New Server

Uploading files in cPanel is straightfoward.
The next thing you can do is upload the backup to the server, then extract it, if you compressed them earlier. Be mindful of the directory though, as different directory means different URL in the web world. Again, depending on your backup size, this can take a while.

Adjust the DB to Your New Server

If you don't change your address/domain/URL, you can safely skip this step.

While the upload is going, you should prepare your DB for the new server. Open that SQL file you got from DB backup earlier, and replace your old URL with the new one.

With the right text editor, you can easily and quickly replace all your old domain with the new one in the SQL file.
You can use any text editor you like, but I personally recommend Notepad++ for Windows, or Atom for both macOS and Windows, as both of them are simple, powerful, and most of all, free.

I love both Atom and Visual Studio Code because they're free, powerful, and cross-platform.
Import SQL File to Your New DB

Now, even though your upload is complete, your site won't work because your DB is empty. In fact, it might throw an error. To fix this, import the SQL file you just modified to your new DB.

Import your recently-exported SQL file to "move" your DB to the new server.
If you're using PHPMyAdmin, you can use the 'import' tab to do this. Click 'Browse', then 'Go'. Wait until it is complete.

Check If Everything Works - Enjoy Your New Site!

Last but not least, once everything's done, check if your site fully works. Try navigating here and there, taking a look at your posts, media files. You might want to take a look at your themes and plugins. In some cases, you might need to re-install them.

Everything works? Great. Enjoy your new site!

Alternative: Premium Services

If you feel that doing it yourself is too bothersome, there are some services out there that can do the job for you for a fee. Heck, your new hosting company might also offer this service.

Fantasktic is one of the companies that provide Wordpress migration service. I never used them, though.
Personally, I've never tried any of them, so I can't really give any recommendation. Besides, if you're migrating often, this can be expensive, so be wary.

Well, that's it. Not that difficult, right? I've tried and tested the above methods multiple times, so it should work. If it doesn't work for you, have your say in the comments below and I'll try my best to help. Finally, as usual, thanks for visiting and see you in the next article! :D


Popular posts from this blog

Logitech mk240 Mouse Combo Review

Smartfren M2Y 4G Mi-Fi: A Pebble That Connects To The World

Which WinRAR Compression Do You Need? [GUIDE]