Community Documentation

D6 Multi-Site Prior to D6.24 - Add a patch to synchronize file paths between dev and prod/live sites

Last updated March 4, 2012. Created by nwwoman on November 25, 2009.
Edited by jhr, JBstrikesagain, redndahead. Log in to edit this page.

The patch this page references has been closed and is now included in Drupal 6.24+.

If you have built your Drupal site on a development machine using multi-site configuration, you've discovered that there's a headache that will occur once you've ported your site to its live box. If you are about to do this, then you'll soon see the problem.

The problem lays within the site/files directory. Once you've uploaded your development site to its live server, you'll discover that you have to go into your tables and change the paths for images and other files. On your development box, you named, just for the sake of example, your site: drupal/sites/mygreatwebsite.com And in both of these directories, you've added a files directory.

To the world, that site will be: thegreatestwebsite.com and its file structure is drupal/sites/thegreatestwebsite.com Once you went live, you'll see that the paths to your images, pdf and other files looks something like this: http://thegreatestwebsite.com/sites/thegreatestwebsite.com/files/myimage...

On one hand, you gulp at the length of that url. Next, you sigh because you realize that you have to change the path -- in the database.

Drupal 7 has a fix for this -- not the length (that's another story) but for the path problem.

And, while it won't be committed to Drupal 6, there is a patch that you can add to Drupal 6 -- if you don't mind doing that no-no: patching core.

You'll find the patch here: http://drupal.org/node/231298#comment-3769752 It's called: d-6.19-directory-alias.patch

Here are the steps I used to install this on a WinXP machine. To do patching, I use cygwin patch utility. Please change words that are italicized to domains/paths applicable to your site.

1. Place patch in apache2triad/htdocs folder
2. In command screen go to apache2triad/htdocs/drupal folder
3. Run the patch: patch -p0 < ../thepatch.patch
4. Make sure there is a files directory located as follows: apache2triad/htdocs/drupal/sites/water/files
5. Production and development sites should BOTH contain: sites/water/files
6. Files system path on both local development box and production site ---- sites/water/files
7. Create a file named "sites.php" and put it into: drupal/sites/ Content of file:

<?php
      $sites
= array(
       
'water.uida.local' => 'water',
       
'water.uida.edu' => 'water',
      );
     
?>

Note that this file can also be created by copying the default.sites.php file created when the patch was installed. Copy it and rename it to sites.php Open the file and remove the hash marks (#) that are located in front of the array at the bottom of the file. Replace the variables in the array with your configuration.
8. Clear caches. Run update.php if you are updating an already created site.
9. Add a "hacks.txt" file to your site, perhaps, to make sure others know about this core change and how it affects updates.

If you are doing this on an established site, you'll need to modify the path for your images/files as they'll be pointing to the old directory under sites.

Comments

No patch at URL!

Correct patch

The latest patch in the correct issue is http://drupal.org/node/231298#comment-2847662

there is a newer one as of

there is a newer one as of November 30th. I updated the article to include the new patch:

http://drupal.org/node/231298#comment-3769752

Page status

About this page

Drupal version
Drupal 6.x
Audience
Designers/themers, Programmers, Site administrators

Archive

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here