zoo
zoo

Reputation: 105

modules on drupal sub-domains

My drupal site gets very heavy and slow as new modules are loaded. Some of these modules aren't needed except for the store section of the site.

I'm thinking to create a store sub-domain and somehow load those modules only in that sub-domain.

Upvotes: 1

Views: 234

Answers (2)

berkes
berkes

Reputation: 27583

If you look in the settings.php, it has a very good explanation of what is called multisite.

From settings.php:

 * The configuration file to be loaded is based upon the rules below.
 *
 * The configuration directory will be discovered by stripping the
 * website's hostname from left to right and pathname from right to
 * left. The first configuration file found will be used and any
 * others will be ignored. If no other configuration file is found
 * then the default configuration file at 'sites/default' will be used.
 *
 * For example, for a fictitious site installed at
 * http://www.drupal.org/mysite/test/, the 'settings.php'
 * is searched in the following directories:
 *
 *  1. sites/www.drupal.org.mysite.test
 *  2. sites/drupal.org.mysite.test
 *  3. sites/org.mysite.test
 *
 *  4. sites/www.drupal.org.mysite
 *  5. sites/drupal.org.mysite
 *  6. sites/org.mysite
 *
 *  7. sites/www.drupal.org
 *  8. sites/drupal.org
 *  9. sites/org
 *
 * 10. sites/default
 *
 * If you are installing on a non-standard port number, prefix the
 * hostname with that number. For example,
 * http://www.drupal.org:8080/mysite/test/ could be loaded from

So. You would make a directory store.example.com and place a settings.php only for that domain. Inside that directory, create a directory modules and place all the modules in there that should appear only for that domain.

Upvotes: 4

user113292
user113292

Reputation:

If you create a second site on a different domain, you're essentially creating a second, separate site with different user stores, different configuration, and different databases.

The one thing you wouldn't have to do is reinstall Drupal or redownload all the modules: Drupal supports something called multisite confgurations, which allows you to have multiple sites running off the same Drupal install. If you make sure the modules you want to share for both sites are in the sites/all folder, all you'll need to do is create a new folder for each website in the sites folder with the domain you want.

For example, if you have mydrupalsite.com and store.mydrupalsite.com, you'd create two folders in the sites folder called mydrupalsite.com and store.mydrupalsite.com. In those folders, you'd have settings.php and a files folder which contains all the files for that specific site.

You can read more about Drupal's multisite feature on Drupal.org.

All that said, what you're describing is probably not the best way: syncing two sites together with disparate user and data stores is a real pain to maintain. And unless a module calls hook_init() or other global hooks, it's loaded on demand when a page actually uses one of the hooks it implements.

With that said, there is a module in core, Throttle, which will let you specify which modules to turn off when the site gets congested.

But Throttle only goes so far. You should probably start to look into caching mechanisms, like Boost, Memcached, Varnish, or even Pressflow if you want to get the most performance out of your Drupal installation.

Upvotes: 5

Related Questions