This is a simple howto for moving single coded website to a multi-site environment. I had a few White Screens Of Death (WSOD) before I gained the wisdom to write this (and hopefully help others).

the environment.

So, Drupal 7 website is created (www.site1.com) and we would like to take advantage of Drupal's multisite functionality by adding a second site (www.site2.com) that will be using the same libraries, modules and themes as in www.site1.com.

Probably on a shared web-hosting and just want to make life easier.

We already know that libraries/modules/themes placed in /sites/all will be used for all websites, and libraries/modules/themes placed in /sites/site2.com will be used by site2.com only.

We already know that we should take out (uninstall and delete) any libraries/modules/themes that aren't used in site1 or site2.

The first website is using the primary domain name, which by default points to /public_html. This website domain name is not a site that has a content, it's the 'master site', the 'bearer'.

www.site2.com already has content, so we only want to move it from a single setup to a multi-site environment under www.site1.com, within the same hosting provider.

The steps

  • Backup the files and the database
  • Put site2.com offline
  • Update Drupal core and all the libraries/modules/themes to their latest releases; both on site1 and site2, so they have the same release number
  • Run database updates on both
  • Create a folder site2.com (no www) and place it in the /sites folder of the site1.com installation.
    So it looks like this: /public_html/site2.com
  • In site2.com, change the files directory to /sites/site2.com/files
  • Copy all the libraries, modules and themes that were used in site2.com to /sites/all
    ...this is essential: if Drupal (the mysql) has been configured for single use, it will search for the libraries/modules/themes in /sites/all only
  • Copy the /files directory of site2.com to /sites/site2.com, so it now looks like this: /public_html/sites/site2.com/files
  • Copy settings.php into the site2.com folder, so it looks lie this: /public_html/sites/site2.com/settings.php
    Don't change a single word in settings.php
  • In the control panel (od site5.com), point site2.com to the folder of site1.com - in my case, to /public_html
    ...Drupal will do the rest
  • Type www.site2.com in the web-browser and arrive at site2.com that is now using the shared codebase of site1.com
  • Run site2.com/update.php just to make sure that all is good.

Disable update checks for site2.com (they are enabled for site1.com)

If a specific module is to be used only for site2,

  • Disable that module in both site1 and site2 and uninstall/delete it.
  • Move the module to /sites/site2.com/modules.
    So, for admin_menu it looks like this: /public_html/sites/site2.com/modules/admin_menu
  • But then checks for updates for site2.com should be re-enabled, otherwise one wont be able to see the update to this module. Same for themes and libraries

If an update Drupal from say 7.15 to 7.16 is performed, /update.php needs to run on both site1 and site2 immediately. The same applies to any upgrade of modules or themes.

Security warning: In /admin/reports/updates/settings, one should click "Check for updates of disabled modules and themes", so that modules that are not used on the master Drupal installation (site1) are checked, especially for security updates.
Again, don't keep modules that are not used on any website.

Comments

bdornbush’s picture

All the above makes sense to me. The one time I tried to do something like this, I ran into trouble because image files had been linked into nodes as sites/default/files/image.jpg and of curse, Drupal couldn't find them in sites/site2.com/files. I ended up copying all of the image and linked (pdf) files into BOTH sites/default/files and sites/site2.com/files. What would be nice is a script that would go through the nodes of site2.com and change the links for files from sites/default/files to sites/site2.com/files.

Are there other such gotchas to think about? I am asking because it has come up again for me.

W.M.’s picture

You can do the changes in paths using SQL replace function inside MySQL console or inside PHPmyADMIN.

salijackt’s picture

I was doing well until I got to this part:

In the control panel (od site5.com), point site2.com to the folder of site1.com - in my case, to /public_html
...Drupal will do the rest

I'm not sure what I'm supposed to be doing?

iceph03nix’s picture

You may have figured this out already, but for people who are finding this later, All the domains that will be using the core files need to be pointed at the main drupal root (where the drupal files are extracted to) It's the folder where you will find 'index.php' and 'install.php'

If all your sites are drupal, this will most likely be in the 'public_html' folder on a shared hosting site using cpanel. If you're drupal is set up in a different directory, you'll need to point it there.

ALL of you're domains sharing a drupal core will point to the same place.

francescosciamanna’s picture

I would like to add that: you need also clear session information to prevent cookies runs into conflicts between the single site(old) and the multisite(new).