Moving A Single Drupal Install From Default Directory To Multi-Site Drupal Installation


Recently I decided to modify my configuration of Drupal 6. Previously, I had just one site, and I had innocently left everything in the default/ directory. This install in retrospect was easy but not an example of good planning. I later had to do some minor changes when I decided to migrate to multi-site.

When it later became clear that I wanted to host multiple sites, I had to move my 'files' directory from inside of /sites/default to /sites/central-america-forum.com. That was easy enough. I moved the settings.php file, cleaned the cache (I have devel module installed), fixed my hard-coded logo URL in my custom theme (oops) and it was running without a hitch.

except... I then realized that my modified installation hadn't properly transferred knowledge about the exact location of the images. Most images were not displaying - not Random Image block, not user thumbnails, etc.

So then I found some tips on Drupal: changing "files" directory configuration setting. No problem. I didn't even put the site in maintenance mode. I just backed up the db, fired off this sql: update files set filepath replace (filepath, "sites/default/files", "sites/central-america-forum.com/files") ; and most images were back.

Except.. User thumbnails not showing up. So I fired up firebug for drupal (I had this module installed), and examined the queries for the user page... eventually I realized 'duh' and just went to the database and did 'describe users' which made it clear that there was a 'pictures' field equivalent to the 'filepath' field... executed this sql update users set picture replace (picture, "sites/default/files", "sites/central-america-forum.com/files") ; And it seems that everything is now working nicely. Of course the htaccess and robots.txt files are shared, which I might have to consider seriously in the future, but for now I think it's ok.


NB - Update - January 1, 2010. I just received the following news about a drupal module that can help you automate this migration:

I just wanted to let you know that based on your post and experiences I've had of migrating sites in a mult-site setup I've created a module to make it much easier. I also wanted to add it to your post for other users who happen to find your blog post as I did when I was looking for an easier way to migrate.

http://drupal.org/project/sitedirmigrate

So in some ways this module was created thanks to you and your blog post!

-Andrew Riley