Search
Close this search box.

How to Move WordPress to Another Server

One question often comes up at our WordPress Sydney meetup is

How do you move WordPress to another server?

It’s easier than you may think and doesn’t require any programming.  You just need to follow a process.

Note: December 2018. This article has been updated from its original post in 2012.

Slideshare

If you’d just like to jump into the slides for the talk, see below.

The Method to Move Your WordPress Site

There are two core components that you need to do, to successfully move your WordPress website to another server.

  1. Move all the files
  2. Move the database

Moving All the Files

This is a pretty easy process but can take a long time to download and upload the zip file depending on how big your website is.

The process is this:

  • Old Server: Zip up all the files in the root folder (sometimes called /public_html/ or /www/)
  • Old Server: Download the zip file to your local machine
  • New Server: Upload the zip file from your local machine to the new server
  • New Server: Unpack the zip file in the root folder
  • New Server: Check database details in the wp-config.php file so they match the new server

Moving the Database

This is a lot more complex and is the part that usually stumps people and gives them a headache.

There are some things to consider here before jumping into the process:

  • Has your domain name changed?
  • Have you moved WordPress from a sub-folder to another location?
  • Is this a new site or are you moving it back from local/development/staging to live production again?

Why did I ask these questions?

WordPress stores the majority of post content in its database (except for images and other file assets), and this includes cross-linking of your own posts and media files,

Absolution URL links are stored in the database, not relative ones.

A relative URL has the format /a-sample-post/ and is relative to your root or primary URL https://mydomain.com.au/ for example.

An absolute URL is an entire link to your post including the root URL https://mydomain.com.au/a-sample-post/.

Change of Domain Name

When you change the domain name of your website, the absolute URLs stored in the database also need to be changed otherwise they would point to the wrong location on the new server.

Change of Folder Structure

When you change the folder structure of your website, for example from https://mydomain.com.au/wordpress/  to https://mydomain.com.au/ again the absolute URLs stored in the database need to be changed otherwise they will point to the wrong location on the news server.

So, even though the domain name has not changed, if you change the WordPress installation folder, you should treat this move in the same way as if your domain name has changed – see slide 13 in the slides.

Brand New Site or In a Development Cycle

If this is a brand new site that has not yet been put on a live (production) server, then you don’t have to worry about GUIDs.  Forget them and carry on.

If your site is in a development cycle where you pull a copy from the production server to local/development/staging, modify stuff then push it back up to production, then you probably don’t want to be changing any post GUIDs when you are renaming URLs in the database.

This would likely be bad for anyone who has subscribed to your RSS feed or any other apps that connect to your site.

Read our article on Never Changing WordPress Post GUIDs.

A Word on Serialized Data

Sometimes, WordPress will store URLs in the database along with related metadata and attributes from a data array.

These are stored as serialized data – see slide 14 in the slides.

Serialized data is stored in this format, for example:
{s:33:”https://zeropointdevelopment.com/”}

Where s:33: is the number of characters in the following string – it’s length.

If you blindly change the URL in the string with a search and replace in a text editor, the length of the string will no longer match the value stored in s: and WordPress will invalidate that data.

This can result in your widgets, menus, customizer, theme and other data going “missing” after you migrate.

Moving the Database Using WP Migrate DB (and Pro)

WP Migrate DB is a plugin that helps you move your WordPress database from one location to another and I have used it to move thousands of WordPress sites over the years.

There are two versions, a free one and a premium Pro version which you have to buy.

You can move your site using just the free plugin, however, the Pro version makes it much much easier.

WP Migrate DB Free Version

You should download the free plugin from WordPress.org.

With the free plugin you can:

  • Rename URLs in the database including in serialized data
  • Optionally rename GUID’s
  • Save renamed database file to your local PC as a *.sql.gz archive

Once you have the renamed SQL file, upload it to the new server and import it using PHPMyAdmin or equivalent database tool from your hosting control panel, into the relevant database – see slide 18.

If your database file is too large and gets rejected by PHPMyAdmin (it’s actually PHP that has a file upload limit), there are other ways of importing your SQL into the database – see slide 19.

You can:

  • Use SSH and import the unzipped file manually from the command line
    mysql -u DB_USER -p DN_NAME < file.sql replacing DB_USER and DB_NAME with those in your wp-config.php file
  • Try using the Big Dump script
    May sound a bit rude but it does work, sometimes
  • Manually split your large SQL file into several smaller chunks.
    Really, don’t choose this options – I have done this in the past and it is not fun

WP Migrate DB Pro

You should buy the Pro version from the Delicious Brains website.

With the Pro version you can:

  • Pull/Push directly to the DB server on both old and new servers
  • Detects PHP and other settings to minimise issues such as large files or timeouts
  • Select which tables you want to migrate
  • Plugin support and updates
  • Migrate your media files to the new server

Moving the Database Using WP-CLI

WP-CLI is a command line tool for managing WordPress installations.

If you don’t know what SSH is or never use the command line (Bash) then you may have to do a bit of reading up on those first, however, it would be well worth it as WP-CLI is freaking awesome.

I would suggest you read Japh’s slides on Migrating a Site Quickly with SSH and WP-CLI if you’re interested in learning.

One change I would recommend is on slide 33 using the –skip-columns=guid parameter when performing the search and replace.

Read our article on Never Changing WordPress Post GUIDs.

With WP-CLI, once you have imported the SQL into the database from the old server, run this command in SSH from the root folder of the WordPress website:

wp search-replace olddomainname.com.au newdomainname.com.au –skip-columns=guid

Wow, how super easy is that!!

Other Methods

Some other methods of moving your WordPress site worth mentioning (slide 24) are:

  • XCLoner
    Only if you are moving to another server using the same domain name (cloning)
  • BackupBuddy (paid version)
    You can “move” your site using the deploy feature
  • Use Git
    Using a “deploy” branch, push or pull to the new server.
    Doesn’t do the database though 🙁

Watch Out For

Sometimes these things can cause a hiccup when moving your site:

  • .htaccess
    This file is used by the Apache server to make your URLs look nice (pretty permalink) and it also performs rewrites and file access
  • Caching Plugins and Services
    You will want to purge your cache files on the new server if you use a WordPress caching plugin or from your service control panel for the likes of Cloudflare
  • Web server
    If your new hosting plan uses a different web server, this can cause an issue with migrations.  Going from Apache to Nginx or vice versa.  Talk to your host about that.
  • PHP version
    If you are moving to a host that has a higher PHP version, that could cause issues if you have an out-of-date theme or plugin. Again talk to your hosting company about that.

Conclusions

Hopefully, I’ve explained well enough for you to try this on your own.

It’s not overly complex and certainly can be done by anyone with some time and the willingness to follow some processes.

Let me know if this helped you move your WordPress site to another server.

Was this article helpful?
YesNo