In this post, I describe how to move a Drupal based website from a single site installation to a multi-site installation. The instructions are centred on Debian/Ubuntu, but should be easy to adapt to other setups.
Here at Kitson Consulting, we host a number of Drupal sites for our clients (and for ourselves, as this blog runs on Drupal). Hosting them in a multi-site environment greatly reduces maintenance headaches, as Drupal's upgrade process is fairly complicated, and upgrading several sites individually takes considerably longer than upgrading a single multi-site installation. Consequently, when setting up a new site, we tend to add it to the multi-site setup. Occasionally though, we need to migrate a Drupal site in from elsewhere, where it was originally set up as a single standalone site, and that's where this article comes in. I was unable to find a clear explanation elsewhere of the steps required, so I hope this article is useful to others in the same situation.
For simplicity's sake, I will assume that you have a working single site install ("old" site) and a working multi-site setup (the "new" site), and that both are at the same version of Drupal. If they aren't, go away and upgrade one so that the versions match before continuing with this article, we don't want to make this any more complicated than necessary! I also assume that both sites are on the same server, although the steps are fairly straightforward to adapt if this isn't the case.
There are essentially four steps:
Move the site configuration file.
Move the site modules, themes, etc.
Move the site files.
Update the database references.
To start, set your old site to one of the default inbuilt themes, turn off all caching, page compression, etc, clear the caches, and turn on maintenance mode. Then log out.
In your multi-site install, create a folder called sites/example.com
(where example.com is the address of the site you're moving).
for the old site tosites/example.com/settings.php
for the new site.
Similarly, copy sites/all/themes
Your website filesystem should now be correctly in place in the multi-site install. Now it's time to fix the database. Run the following commands on the site server, putting in the database password when prompted:
mysqldump -u [site_database_user] -p [site_database_name] > old_site_database.sql
sed s@sites/all/@sites/example.com/@g old_site_database.sql > new_site_temp_database.sql
sed s@sites/default/@sites/example.com/@g new_site_temp_database.sql > new_site_database.sql
mysql -u [site_database_user] -p [site_database_name] < new_site_database.sql
Briefly, these instructions dump the entire database to a text file, do a find/replace on "sites/all/" → "sites/example.com/" and "sites/default/" → "sites/example.com/", and then overwrite the database with the updated version.
The database should now be sorted, so all that remains is to tell your webserver (I assume Apache) that the site lives in a different place now. Adjust your Apache config for the site to point from its old location to the new location, e.g. by opening /etc/apache2/sites-available/example.com
and changing DocumentRoot /var/www/example.com
to DocumentRoot /usr/local/share/drupal
. Any Directory
options and similar will also need to be edited. Run apache2ctl configtest
to check there aren't any mistakes, and then run service apache2 reload
to load the new config.
Congratulations! You should now be able to visit your site URL and see the site running correctly from its new multi-site home. Log in, re-enable your theme, turn compression and caching back on if you use them, and finally turn maintenance mode off. Ta-da!
I followed this guide exactly as described, but still I'm not able to migrate my old single site to my new multi site. Having followed all described steps and trying to access my newly migrated (now multi site) site, I just get a white screen not showing anything. The apache error log says: "PHP Fatal Error: Call to undefined function user_access() in '/home/drupal/public_html/includes/menu.inc' on line 634. With that message, I'm kind of stuck. Am I missing any important step? I'm trying to migrate a drupal 7.27 minimal single site installation to a drupal 7.27 minimal multi site installation.
Any help would be highly apreciated! Thanks!
That sounds like a general Drupal problem rather than a problem with the change to multi-site. Have you definitely copied across all of the modules and themes from your old install?
The only other thing I can suggest is to try to copy the site from its old single-site install to a new single-site install, and see whether the same issue appears. If so, then you can be sure it's a general Drupal problem rather than a multi-site specific problem.