Sunday, May 10, 2015

Correctly Using Registry Rebuild in a Multisite Installation with Drupal 7

If you have a multisite Drupal installation and need to run Registry Rebuild follow the instruction below. As the first line in the download page states, remember this is not a module and you can't enable it. And if rightly set you can rebuild your Registry with ease.

Download the files and place it inside the folder of the website whose registry you would like to rebuild. Say, suppose your multisite is as follows:

1. www.example.com (Main Site)
2. www.abc.example.com (Multisite 1)
3. www.123.example.com (Multisite 2)

& you would like to rebuild the registry for Site #2 viz. www.abc.example.com.

So your folder structure for the websites below might be something like:
 /var/www/html/www.example.com  
 /var/www/html/www.example.com/sites/abc.example.com  
 /var/www/html/www.example.com/sites/123.example.com  

Extract and check the files inside your registry_rebuild folder. The file to note here is 'registry_rebuild.php.' Open it in an editor of your choice and make the following edit in line 10.

Change
 define('DRUPAL_ROOT', define_drupal_root());  
to
 define('DRUPAL_ROOT', $_SERVER["DOCUMENT_ROOT"]);  

This will help you get the appropriate Drupal Root for each of your multisites else you will get an error as below:
 Failure: Unable to discover DRUPAL_ROOT. You may want to explicitly define it near the top of registry_rebuild.php  

Now place the registry_rebuild folder that you just extracted inside the multisite folder whose registry you want to rebuild; in our case it's abc.example.com and access it as below in your browser:
 http://abc.example.com/sites/abc.example.com/registry_rebuild/registry_rebuild_multisite.php  

The process will take some time and you might just see a blank browser. Finally if your registry has been successfully rebuilt you should get a confirmation message as below:
 DRUPAL_ROOT is /var/www/html/projects/example.com.  
 Bootstrapping to DRUPAL_BOOTSTRAP_SESSION  
 Bootstrap caches have been cleared in DRUPAL_BOOTSTRAP_SESSION  
 Doing registry_rebuild() in DRUPAL_BOOTSTRAP_SESSION  
 Bootstrapping to DRUPAL_BOOTSTRAP_FULL  
 Rebuilding registry via registry_rebuild_cc_all in DRUPAL_BOOTSTRAP_FULL  
 All caches have been cleared with registry_rebuild_cc_all.  
 There were 616 files in the registry before and 616 files now.  
 All caches have been cleared with registry_rebuild_cc_all.  
 If you don't see any crazy fatal errors, your registry has been rebuilt.  

Now you should be able to access your site.

Note: Also if you are using VirtualHost then make sure your Document root is the path to the main site folder as below and not the multisite folders inside the 'sites' directory:
 DocumentRoot /var/www/html/example.com  
and not
 DocumentRoot /var/www/html/example.com/sites/abc.example.com  

No comments:

Post a Comment

Thank you for your Feedback!
www.evagabond.me

Top Magento Hosting:

Top 5 Posts (Weekly)

Lets Connect: