How to move Drupal to new server
If you are moving Drupal 8+ we suggest following the websitemigrationguides.com guide "HOW TO MOVE A DRUPAL 8 WEBSITE TO A NEW HOST".
So you've had enough of your current hosting company, fed up with downtime and just want to move Drupal to a new server? This isn't surprising, a Drupal site needs to be quick and to respond fast and a slow server wont do either. Well the good news is the guide below will explain how you can leave your server/old hosting company and move to another. The below guide is written mainly for users who want to move to us (Squirrel Hosting) but it should work for any company. Please note this guide appears longer than it actually is as we have listed literally every step with pictures so even Drupal newbies can move servers with ease. If you have a rough idea of FTP-ing and databases you will be able to skip quite a lot of this guide.
Please note this guide assumes you have already purchased Drupal hosting either from Squirrel Hosting or another company.
Step 1 : Check your Drupal Version and update!
OK the first thing to do is make sure your Drupal site is up to date. Nothing's worse than moving to a new hosting company, finding out something on the server (e.g. php version) is different and only the latest Drupal supports it. For details on how to do this, see http://drupal.org/upgrade/
With that said let's start the guide on how to migrate drupal to a new server.
Step 2a : Backup your site automatically
Most modern hosting companies will provide a 1 click automatic backup feature which can backup your sites database and website files in a few clicks. If your server does support this we strongly suggest using it to back up everything and skip to step 3. If it doesn't provide this feature then you can use the below step 2b to back everything up.
Step 2b : Backup your site manually : Drupal FTP Backup
What you will need to do is connect via FTP to your server (don't worry it's not as scary as it sounds). For this guide we will use FileZilla FTP Client as it's great and free! You can grab yourself a copy at http://filezilla-project.org.
You will also need to contact your current host and ask them for the following details:
- Server FTP Host
- Server FTP User name
- Server FTP Password
- Server FTP Port number (usually 21)
Once you have these, open up FileZilla (on windows PC, click the windows icon in bottom left, click all programs, click FileZilla FTP Client, click FileZilla) and enter your host, user name, password and port number at the top of the page. Then click connect.
FileZilla should now connect to your server and when done should display some folders. These folders vary depending on which hosting company you are with. What we need to do now is navigate to the folder where your Drupal site is installed. This folder is usually called htdocs or public_html. Double click this folder to navigate into it.
Once in your Drupal directory (you should see files like index.php, update.php, xmlrpc.php etc if you're in the right directory) we want to highlight all the files listed and copy them to a folder on your computer. In this Guide we copied them into a folder on our desktop called 'old site'. To do this, simply click on any file once to highlight it then press the CTRL key on the keyboard and the letter A. This should highlight every file for you. Then it's simply a case of clicking on a file and whilst still keeping the mouse button pressed, moving the mouse over your folder (old site), then letting go of the mouse.
If you did this correctly you should see a lot of green and black writing appear at the top and files should start appearing in the 'old site' folder on your desktop.
Once FileZilla has finished downloading all the files, the text will stop scrolling and display something along the lines of 'File transfer successful, Status: Disconnected from server'. You can now close FileZilla.
Step 2c : Backup your site manually : Drupal MySQL Database Backup
The next thing we need to do is backup your Drupal MySQL Database. To do this we will use phpMyAdmin. This is a web interface which 99+% of hosting companies have installed. Contact your hosting company and ask them how to access phpMyAdmin. Usually this is in your Control Panel and has an icon like the one below.
Once you have located it, open it up and look for your Drupal Database on the left hand side. This database will probably have the word Drupal or something similar in it.
TIP: If you have lots of databases you can look in your 'old site' folder, open up the settings.php file in sites\default folder. Scroll down until you see 'database' => 'YOUR DATABASE NAME'. The YOUR DATABASE NAME is the name of your Drupal database. It is usually at around line 208.
Click your database to load it up.
Next click the export tab at the top.
On the page that loads, click the custom radio button to bring up more export options.
Next to the compression option, choose Zipped from the drop down box.
Leave all the other options as they are and click go.
It should prompt you to save a file to your computer. Save this next to your 'old site' folder.
That's it, you now have a full backup of your Drupal site.
Step 3 : Set up a new database on your new hosting.
OK so what you need to do now is create a new database on your new hosting account. Below are instructions on how to do this with Squirrel Hosting. For other hosting companies, you will need to contact their tech support. Alternatively you can browse your control panel and see if you can find it yourself, shouldn't be too well hidden!
Squirrel Hosting customers, click the control panel in the top right at www.squirrelhosting.co.uk.
Enter your Squirrel Hosting user name and password then click login.
Click 'Manage your hosting'.
Click 'Load eXtend Control panel'.
In the pop up window, click the MySQL icon
Under the 'Create a MySQL Database' section enter a user name and password of your choice. Then click the 'create' button.
This will now have created a Database for your Drupal site and it should be listed below.
Make a note of the Username and Password as we will need these later. Once you have these, click the 'now' button under the manage tab to load up phpMyAdmin for this database.
Step 4 : Insert your Drupal Database.
In this step we will insert the Drupal database from your old site. In phpMyAdmin click your new database from the menu on the left.
Next click the import tab at the top.
Next click the choose file button and select the old Drupal database file we downloaded in step 2c (the Zip file).
Once complete, you should get a message stating so.
That's it for your database. You can now close any phpMyAdmin windows you have open.
Step 5 : Edit your /sites/default/settings.php file
Your settings.php file will have your old database user name and password. In order for the new site to work we will need to update these to show the new user name and password we made earlier in step 3.
Open up your old site folder (or whereever you downloaded Drupal to on your computer) and double click the sites folder to open it up. Then double click the default folder. Once loaded you should see a file called settings.php. We need to open this file with a plain text editor such as notepad. Double click it to open it.
TIP: Do not open this with Microsoft word or another rich text program, it will mess the file up! Only use plain text editors such as notepad.
Once open, scroll down to line 208ish where you will see
'database' => 'Your old database', 'username' => 'Your old username', 'password' => 'Your old password', 'host' => 'localhost',
We will need to change these to match your new database. Change these to say
'database' => 'Your new database', 'username' => 'Your new username', 'password' => 'Your new password', 'host' => 'localhost',
These are the details you wrote down at the end of step 3. On Squirrel Hosting your database name will be the same as your user name. Once you have made the changes, click save.
Step 5 : Upload your files to the new Drupal server.
The final step is to upload all your old Drupal files to the new server. To do this we need to connect via FTP and drag the files from the 'old site' folder onto the new hosting public_html (or htdocs) folder.
Squirrel Hosting users can find their FTP details (and unlock the FTP) using the below guide. If you're using another company, you will need to ask them for your new FTP details.
Log into your squirrel hosting account at www.squirrelhosting.co.uk and click 'manage web hosting'. Then click, 'Load eXtend Control panel'. Once loaded, scroll down and on the right hand side you should see a box labelled 'unlock FTP'. Choose 1 Hour from the options and click the unlock button.
Next scroll down a bit further and you will see your FTP Host/server user name and password. Write these down.
Next, open up FileZilla and enter your new host's connection details (the ones from above) in the boxes at the top. For Squirrel Hosting you may leave the port blank.
Next, double click on public_html or the equivalent folder if using another hosting company.
Next we need to upload all the files we downloaded from your old host. Locate the folder where these files are stored (old host) and highlight all the files in the folder (CTRL+A). Finally left click on the files and drag them over onto the empty public_html folder window.
That's it, you have now moved Drupal to a new server!
If you have any issues or would like further help how to move Drupal to a new server, please open a support ticket where one of our staff will be happy to help.
Spotted anything you think is wrong or could be done better, not a Squirrel Hosting customer but stuck using this guide? Drop a comment below and we'll see if we can help.
Leave a comment
Has this guide helped you? Have an idea for a guide or need help? Let us know below.