• Objective: Explain how to make changes to the code without disrupting activity on a live Drupal site
  • Audience: Site administrators with command-line access and skill
  • Topics covered:
    • Create a special .htaccess file
    • Partition the directory for different instances of Drupal
    • Edit Drupal in a couple places to accommodate the partitioning
    • Use symlinks to tie it all together
  • Topics not covered:
    • How to use the command line
    • Install Drupal from CVS or tarball
    • Duplicate the database
    • Accommodate environments without mod_rewrite
    • Accommodate environments without symlinks
  • Other future related documentation:
    • HOWTO: Update the code base of a live site with no down time (less than a second, actually)
    • HOWTO: Test code and theme changes randomly (i.e. perform A/B testing)
  • Questions:
    1. Does someone else have experience in these topics? I'd like to chat with them and compare notes.
    2. Where can I maintain the documentation until it's ready and accepted? Is a Writeboard okay?

Comments

amstercad’s picture

Please refer to step two in this page: (http://drupal.org/node/26434). Is this what you had in mind?

Please note I removed this step 2 from the options I otherwise detailed, in the 'multiple sites' version of this document (scroll to the bottom): http://drupal.org/node/47163

If you would like me add/clarify this to the mulitple-sites docs (linked 2nd, this message), tell me so, be patient, and I'll get it done. I'll do it, but I struggle getting my head 'round with this RewriteBase stuff, so please be patient. In the meantime, maybe the first link in this message will help you.

njivy’s picture

Step 2 is similar to what I have in mind: in both cases, Drupal is installed in a subdirectory and can be accessed as a subdirectory. And symlinks are involved in both cases. But I expect the methods diverge from that point.

I like your naming scheme, though. How would you name this method?

Here's a rough sketch of the method I've been using:

  • Install Drupal into a subdirectory, ./drupal-1. (Subsequent code bases can be installed into ./drupal-2, ./drupal-3, etc.)
  • Make a symlink to the active Drupal subdirectory, ./drupal-active -> ./drupal-1.
  • Edit $base_url in settings.php to include the subdirectory, http://www.example.com/drupal-1.
  • Edit the RewriteBase in .htaccess in the subdirectory.
  • Edit .htaccess in the parent directory so that it internally redirects to the active Drupal subdirectory, ./drupal-active. The address in the visitor's browser never changes.
  • Add a line to the index.php in each subdirectory to reset $base_path. This makes all rendered links point back to the parent directory, which is what the visitor expects.

There is a catch: If two Drupal installs are active at once (e.g. under A/B testing conditions), the page cache keys will be the same since this method mangles the $base_path. Two small tweaks to page caching functions work around this problem. But the method would be more palatable without the tweaks.

So with the following directory structure (and some other preparation), the Drupal installed in ./drupal-1 looks to the visitor like it is installed in the parent directory.

parent-directory/
parent-directory/drupal-0/
parent-directory/drupal-1/
parent-directory/drupal-2/
parent-directory/drupal-active -> ./drupal-1

Would you like me to continue sketching the method here for you to document?

njivy’s picture

If the contents of settings.php are the only difference between two code bases, this method makes further use of symlinks. For example,

parent-directory/drupal-1/sites/settings/default/settings.php
parent-directory/drupal-1/sites/settings/www.example.com.drupal-alternate/settings.php
parent-directory/drupal-active -> ./drupal-1
parent-directory/drupal-alternate/includes -> ../drupal-active/includes
parent-directory/drupal-alternate/sites -> ../drupal-active/sites
...
emmajane’s picture

Component: Installation » New documentation
Status: Active » Closed (fixed)

Under: http://drupal.org/upgrade/tutorial-introduction there is a section on http://drupal.org/upgrade/preparing-the-site which includes information on safely upgrading a site.