Move Drupal multisite to single site

April 3, 2014

Drupal multisites have a smaller memory footprint and can be updated simultaneously. On the other hand, only one shared PHP version can be used and if something is wrong with a dependency, all the websites can be down at once.

Multisites add an extra unnecessary layer of complexity. And nowadays, with drush and git at our disposal for fast updates and deployment, I would argue against using multisites. Just stick with the defaults as much as you can.

But what if you want to move a multisite to a single site install?

If you keep the folder structure intact, with a sites/mysite.com folder as the active sites folder, you will possibly encounter problems with the file or theming system. Most common problems are themes that are not loading or pictures not showing up.

Luckily, with some effort, you can make a true single site of a former multisite. Follow along (but don't forget to backup first!):

  1. Create a normal folder structure
  2. Change the Drupal admin to default
  3. Check the database for wrong file system paths

Create a normal folder structure

  • Move the themes, modules and libraries folders from sites/mysite.com to the sites/all folder.
  • Move the sites/mysite.com/files to sites/default/files. Create a new folder if needed.
  • Move the settings.php file from sites/mysite.com to sites/default.

Change the Drupal admin to default

Now login to the website.

This can be hard because of caching or the theme that isn't loading. So use the mysite.com/user/login or mysite.com/admin path. When you are stuck with a white screen, toggle free access to TRUE in settings.php and use drush to clear the caches and to run cron.

Go to appearance, if needed, and activate your theme. Next, change the file system paths so it points to sites/default/files for the files, sites/default/files/private for private files and sites/default/files/tmp for temporary files.

Next, clear all the caches: drush cc all.

Check the database for wrong file system paths

Possibly, when loading the website, you don't see any pictures. The paths of the pictures reside in the database and they are pointing towards the wrong location.

Best thing to do is search the database for sites/mysite.com. If there isn't much data, just change it directly in the database. If there is lots of data in some tables, use search to change the paths. Some common SQL queries like these (just paste these in the SQL box of mysql and click 'run'):

MySQL search

UPDATE system SET filename = REPLACE (filename, 'sites/mysite.com/modules', 'sites/all/modules');

This query looks in the filename column of the system table and changes the string 'sites/mysite.com/modules' with 'sites/all/modules'

UPDATE files SET filepath = REPLACE (filepath, 'sites/mysite.com/files', 'sites/default/files');

This query looks in the filepath column of the files table and changes the string 'sites/mysite.com/files' with 'sites/default/files'

MySQL SQL query

UPDATE node_revisions SET body = REPLACE (body, 'sites/mysite.com/files', 'sites/default/files');

This query looks in the body column of the node_revisions table and changes the string 'sites/mysite.com/files' with 'sites/default/files'

UPDATE boxes SET body = REPLACE (body, 'sites/mysite.com/files', 'sites/default/files');

This query looks in the body column of the boxes table and changes the string 'sites/mysite.com/files' with 'sites/default/files'

It's a good idea to fully empty (truncate) all the cache tables (in mysql) and update the image styles under /admin/config/media/image-styles > edit > 'Update style'

Now you have a normal website again.

Resources you should check:

  • http://www.adammalone.net/post/migrating-multisite-singlesite
  • https://www.youtube.com/watch?v=48ZRWqQn-GE

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.