Drupal 8: manual migration to a different server

The task for me was to migrate a Drupal 8.1 project from one server (where it ran in a subdirectory) to a server where it should run in the root folder on a subdomain (e.g. no Drupal 6/7 upgrade etc., “just” a Drupal 8 copy-paste job). I did this job many times with WordPress projects and it was quick and easy: make a sql-dumb of the database, search & replace the paths, copy the codebase and CMS content and finally import the whole bunch onto the new server.

Needless to say, that’s to easy for Drupal…

It was a drag to find a helpful documentation for such a popular task. After a lot of unsuccessful reasearch, I came across an article about migrating a Drupal 7 installation, and this one helped me a lot. I’d like to share a brief list of how to do it.
Please consider that this how-to is not guaranteed to work for every given occasion, it’s just how it worked for me. And in addition, make backups of everything anytime.

Let’s point out the steps of this article in short and see what we have to apply for Drupal 8:

  1. check if the settings and requirements of the new server (PHP version etc.) at least match or exceed the old server’s requirements
  2. Set the site to maintenance mode
  3. Clear the cache. This is one of the most important steps! The old directory path is stored in the cache data and can be very troublesome on the new server.
  4. Export your Drupal database, e.g. via phpMyAdmin. The simple export will do.
  5. Open the created SQL file and search&replace the base URL (e.g. “http://www.myolddomain.com/subdir/” becomes “http://www.mynewone.com/”). If you previously used a subdirectory like me, replace the string “/subdirectoryname/” with a single “/”.
  6. Download the Drupal code base and any user files, like images etc.
  7. Open the file “sites/default/settings.php” in the downloaded Drupal root folder with a text editor. Scroll to the very bottom. Replace the values in the $databases- and trusted_host_patterns-array and with the the values of the new database resp. domain name
  8. Import the SQL file into your new database and upload the Drupal code base and user files to your new webspace
  9. Like the article says, you may need to alter your new .htaccess file
  10. Visit your new domain. The Drupal site should run now.
  11. Go to the page domainname/user (this seems to be Drupal 8-specific) and log in. Turn off maintenance mode if needed.

If this doesn’t work for you, you may also try the steps in the article which I didn’t include. I guess that turning off clean URLs, renaming table prefixes etc. is not necessary or included in Drupal 8 anymore, but maybe someone makes different experiences since there doesn’t seem to exist “the one and right” way.

Good luck!