【问题标题】:modules on drupal sub-domainsdrupal 子域上的模块
【发布时间】:2010-07-28 18:55:30
【问题描述】:
随着新模块的加载,我的 drupal 站点变得非常沉重和缓慢。除了站点的商店部分之外,不需要其中一些模块。
我正在考虑创建一个store 子域并以某种方式仅在该子域中加载这些模块。
- 这是否意味着我必须安装drupal 两次,一次在
store.mydrupalsite.com 上,一次在mydrupalsite.com 上?
- 在商店子域中,除了专门的商店模块之外,我是否必须重新安装基本模块,或者有没有办法让商店子域以某种方式从主站点继承模块?
- 如果用户已经登录主站点怎么办。他们是否需要重新登录
store 子域,或者有没有办法共享数据库?
- 这个想法有什么真正的好处,还是我把事情复杂化了?
- 如果我把事情复杂化了,我应该怎么做
【问题讨论】:
标签:
php
drupal
content-management-system
【解决方案1】:
如果您在不同的域上创建第二个站点,您实际上是在创建另一个具有不同用户存储、不同配置和不同数据库的独立站点。
您不必做的一件事是重新安装 Drupal 或重新下载所有模块:Drupal 支持称为多站点配置的东西,它允许您在同一个 Drupal 安装下运行多个站点。如果您确保要为两个站点共享的模块都在 sites/all 文件夹中,您需要做的就是在站点文件夹中为每个网站创建一个新文件夹,其中包含您想要的域。
例如,如果您有 mydrupalsite.com 和 store.mydrupalsite.com,您将在名为 mydrupalsite.com 和 store.mydrupalsite.com 的站点文件夹中创建两个文件夹。在这些文件夹中,您将拥有 settings.php 和一个文件夹,其中包含该特定站点的所有文件。
您可以在 Drupal.org 上阅读有关 Drupal's multisite feature 的更多信息。
说了这么多,您所描述的可能不是最好的方法:将两个站点与不同的用户和数据存储同步在一起是维护起来的真正痛苦。除非模块调用 hook_init() 或其他全局钩子,否则当页面实际使用它实现的钩子之一时,它会按需加载。
那个说,核心中有一个模块,Throttle,它可以让你指定在站点拥塞时关闭哪些模块。
但 Throttle 仅能做到这一点。如果您想从 Drupal 安装中获得最佳性能,您可能应该开始研究缓存机制,例如 Boost、Memcached、Varnish 甚至 Pressflow。
【解决方案2】:
如果你查看settings.php,它对multisite 有很好的解释。
来自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
所以。您将创建一个目录store.example.com 并仅为该域放置一个 settings.php。
在该目录中,创建一个目录 modules 并将所有应该只出现在该域中的模块放在其中。