Website Migration Guides

A simple free resource for website migration

How to move a Drupal 8 website to a new server / host

This guide will take you through the steps of moving a Drupal 8 website from one host to another in detail. All of the steps below are using systems such as PhpMyAdmin and FTP that all hosts (or at least the ones worth using!) provide. The guide has been created so that anyone can follow it (no matter your technical experience or which host you are using).

Ok, so let's gets started

Turn off Drupal Caching.

From a little research online it looks like some people have had issues with migrating Drupal 8 when the caching is enabled. As such, we recommend you turn this fully off and clear the caching before starting the migration.

Open your Drupal 8 admin and click the "configuration" button at the top.

drupal admin configuration

Next click the "performance" link.

drupal 8 performance

From the dropdown under the "caching" section select "<no caching>". Under the "Bandwidth optimization" untick "Aggregate CSS files" and "Aggregate JavaScript files" then click the "save configuration" button.

drupal caching

You should now see the message "The configuration options have been saved." Click the "clear all caches" button.

drupal clear all caches

Once complete, you should see a message saying "Caches cleared.".

caches cleared

That's it. You can now move onto backing up your Drupal 8 website for the migration.

Backing up your Drupal 8 files/folders.

Your Drupal 8 website is split into two sections, the files/folders of your website and the database. First you will need to download a copy of all the drupal 8 files and folders. In this guide, we will explain how you can do this using FTP. Whilst many hosts offer a 1 click back up solution, this is often limited to premium packages. However, FTP is almost always available no matter which host you use and as such we have chosen to show how to back up up using this method.

The first step is to create a folder on your computer to store your Drupal 8 backup in. This folder can be called anything you like but in this guide we will call this folder "Drupal 8 backup" and save it onto our desktop for easy access.

Next, contact your current host and ask them for the following:

1) Your FTP host.
2) Your FTP username
3) Your FTP password
4) Your FTP port (this is usually 21).

You can usually find this information in your host's control panel (or in a welcome e-mail) but if not, give them a call and ask for the above details (they will know what you mean).

Once you have this information, you will need to get hold of a FTP client. A free FTP program called FileZilla can be downloaded from Filezilla-project.org (which is the one we have used in this guide) but any FTP client should work although the steps will vary slightly to the ones below.

Open your FTP program (in this case FileZilla) and enter the connection details your host has provided you with then click "QuickConnect".

drupal connect to old host via ftp

Once connected, you should see a public folder which you will need to open. This is usually given the name of 'public_html' or 'htdocs' (ask your host if you are unsure or do not see either of these).

drupal located in public_html folder

Once you have opened your public folder, you should see a list of your drupal files. These will include (but are not limited to) "core", "modules", "update.php" and "web.config". Assuming you can see these files, you are in the right place.

drupal files and folders

In the left hand pane, locate the 'drupal 8 backup' folder you made earlier and open it.

drupal 8 backup folder

Select all the drupal files/folders on the right pane and right click on them, then select 'Download'. Alternatively you can select them all and drag them into your "drupal 8 backup" folder.

download drupal 8 files and folders

You should now see the files and folders downloading at the bottom.

drupal 8 downloading

Once complete, check the failed transfers tab at the bottom for any files/folders that have failed to download. If any are listed, set these downloading again.

Backing up your Drupal 8 database.

To back up your Drupal 8 database, you can use PhpMyAdmin. This is almost always included with hosting packages and is a web interface that will allow you to export your database quickly. This can usually be found in your hosting control panel but contact your host for details if you are unable to locate it.

Once you have found PhpMyAdmin, open it up and if your drupal 8 database has not already been opened, select it from the menu on the left.

select drupal database

You should now see a list of tables. These will include (but are not limited to) "batch", "block_content" and "cache_bootstrap". If you can not see these tables, it is likely you are not in your drupal database.

Click the "Export" tab at the top of the page.

export database

Then click the "Go" button and save the exported file to your computer.

Go Button

TIP : If you have a large database, you may have issues restoring it on the new host in the later stages. As such, you may find it useful to also download a compressed version. This can be done by clicking the "Custom" button, selecting "zipped" as the compression, then clicking Go at the bottom.

Once complete, you can close PhpMyAdmin.

Restoring your Drupal 8 database on your new host

Now that you have a full backup of your Drupal 8 website, you can move on to restoring this on your new hosting. The first step is to set up a new MySQL database and import the backup you made in the previous step using PhpMyAdmin.

How to set up a new database will vary depending on your host's control panel (look for a section called "MySQL databases"). Contact your new host if you are unable to locate it and ask them how to open PhpMyAdmin.

Once you have set up a new database, make a note of the following:

1) Your database host (usually localhost).
2) Your database name
3) Your database username
4) Your database password.

as you will need these later on in the guide.

Once you have these, open your new database in PhpMyAdmin. If your database is not already opened automatically, select it from the left menu.

select new drupal database

Next, click the "Import" tab at the top.

import drupal database

You should now see a database import page. Click the "Choose file" button then select the database you downloaded earier.

Choose database

Then click the "Go" button to start the import.

go import

Once complete, you should see a "Import has been successfully finished" message.

Import has been successfully finished

You can now close PhpMyAdmin.

Updating your Drupal 8 settings.php file

Before you can upload your drupal 8 files/folders you will need to change some lines of text in a file called settings.php. Without making these changes your drupal site will not be able to communicate with the database (and in turn it will act like a brand new install of drupal being set up).

In your "Drupal 8 backup" folder, open the folder called "sites".

sites folder

Next open the folder called "default".

default folder

You should now see a file called settings.php (note the 'php' may not show up if your computer is not set to show extensions). Open this file with a plain text editor such as notepad or notepad++. Do not use a rich text editor such as WordPad or Microsoft word as this will corrupt the file.

locate the line:

'database' => 'AAAAAA',

(yours will have something other than AAAAAA) and change the AAAAAA to your database name.

Next, locate the line:

'username' => 'BBBBBB',

(yours will have something other than BBBBBB) and change the BBBBBB to your database username.

Next, locate the line:

'password' => 'CCCCCC',

(yours will have something other than CCCCCC) and change the CCCCCC to your database password.

and finally, locate the line:

'host' => 'DDDDDD',

(yours will have something other than DDDDDD) and change the DDDDDD to your database host (usually 'localhost').

Once the changes have been made, save and close the file.

TIP : You may see the above lines more than once. If you do, check to see if it has a * in front of it e.g.

 *   $databases['default']['default'] = array(
 *     'driver' => 'pgsql',
 *     'database' => 'databasename',
 *     'username' => 'sqlusername',
 *     'password' => 'sqlpassword',
 *     'host' => 'localhost',
 *     'prefix' => '',
 *   );

If it does, this is not in use and is not the section to edit. Usually the section to edit will be right at the bottom of the file.

Uploading your Drupal 8 files/folders from your back up

You should now be ready to upload your drupal 8 files and folders. To keep things simple in this guide, we will show you how to do this using FTP. Contact your new host and ask them for the following:

1) Your FTP host
2) Your FTP username
3) Your FTP password
4) Your FTP port (usually 21).

Usually, you can find these in your hosting control panel or in your hosting welcome e-mail. However, if not, contact your new host who will be able to provide you with these.

Once you have them, open up your FTP client again and enter the details in the connection boxes then connect.

connect via ftp to your new drupal host

Once connected, locate your public folder on the right (usually public_html or htdocs) and open it.

public folder on your new host

Next, locate and open your "Drupal 8 backup" folder on the left.

Drupal 8 backup

You should now see all of your Drupal 8 files/folders. Select all of them then right click and choose 'Upload'.

upload drupal 8 backup

You should now see all of your Drupal 8 files being uploaded at the bottom of your screen.

drupal 8 backup being uploaded via ftp

Once this has completed, check the Failed transfers tab for any files that did not upload. If any failed, reset them and try again.

Set Drupal's sites/default/settings.php file to read only permission.

Now all of your files are uploaded, you need to make sure that the settings.php file has read only permissions (this is for security). This can be done whilst still in FileZilla. To do this, open the sites folder on the right, then open the default folder. Right click on the settings.php file and click "File Permissions"

settings php file permissions

In the popup box, enter 444 then click 'OK'.

chmod 444 settings

You can now close FileZilla.

Update the domain's nameservers

Once you have done all the above, your Drupal 8 website is ready to launch. However, you still need to tell your domain to look to the new hosting. To do this, you will need to update the domain's nameservers (or DNS A Records) to point to the new hosting company. The steps required to do this can vary depending on your registrar (the company you purchased the domain from). In brief, you would do the following:

1) Contact your new host and ask them for the nameservers.
2) Contact your registrar and ask them to update the nameservers on your domain to the ones your new host provided.

Turn Drupal Caching back on

Once the nameservers have updated (can take up to 24 hours), you should be able to load up your new hosting with your domain. At this stage all that would be left to do is to re-enable caching (which you turned off at the begnining of this guide).

Comments

If this guide has helped you or if you feel it could be improved, please let us know in the comments below.

seizethecarp: In order to change the max upload size, edit upload_max_filesize and if needed post_max_size in /etc/php5/apache2/php.ini (or in my version: /etc/php/7.0/apache2/php.ini )
Wed Jan 31 20:31:58 2018 · Like · Dislike · Total +2 · Reply
atian: C'est super ! Très précis.
Tue Jun 26 21:16:29 2018 · Like · Dislike · Total +1 · Reply

Hi, did this site help you?

I'm John and this little website is my online side project. It isn't sponsored by any company and I rely solely on donations to pay the hosting fees. If this site has helped you please consider making a small donation using the link below.

Thanks again and happy surfing.