drupal 多站点的 apache 配置

drupal 多站点的 apache 配置

我花了一天多的时间尝试使多站点安装正常工作,并且我认为大部分工作都已完成,但是当我访问 www.mywebsite.co.uk/install.php 时仍然看不到 install.php?

我有一个运行 ubuntu、apache2 和最新的 mysql 和 php 5 的专用服务器。

我已经将最新的 Drupal 代码库安装到

/home/d/r/drupal/web/public_html

我已经设置了 drupal 数据库(称为 drupal)并配置了代码库,并且一切运行良好,并且可以在 www.myserver.co.uk/drupal 上查看 drupal 安装,没有任何问题。

我接下来按照以下说明进行操作:http://gotdrupal.com/videos/multisites-vs-multiple-sites并几乎完全按照描述设置了我的 Apache 配置:

这些是我的各种配置文件的内容:

/etc/apache2/conf.d/drupal6.conf:

#============================================================
# Toggle APC cache
#php_flag apc.cache_by_default 1
#This is already enabled in php

<Directory "/home/d/r/drupal/web/public_html">
    # Yeah, better performance - no hits to the file system
    # Loading Drupal's .htaccess into memory is much better
    AllowOverride none

    # Define your own file limitations on drupal files
    <FilesMatch "(install.php|cron.php|update.php|\.txt)$">
        Order deny,allow
#        Include conf.d/ip.conf
# including the line above always caused an error when re-starting apache2 so I have hard coded the IPs below (these are not the ones I am usinb obviously!)
Allow from 123.123.123.123
Allow from 124.124.124.124
        Deny from all
    </FilesMatch>

    # Read in Drupal default .htaccess file asif conf - easier CVS management
    Include /home/d/r/drupal/web/public_html/.htaccess

# Offline mode for multisite setup - see file for more info
# Uncomment the line below to set sites offline
    # Include conf.d/offline.conf

</Directory>

# Sorry, no svn peeking
<DirectoryMatch "\.svn">
    # Currently pointing back to drupal
    # High traffic sites might want custom
    # error pages, no need to load drupal
    ErrorDocument 403 /index.php
    Order allow,deny
    Deny from all
    Satisfy All
</DirectoryMatch>

# Allow the .htacces files to be used in the sites folder where /files are stored
<Directory "/home/d/r/drupal/web/public_html/sites">
    AllowOverride
</Directory>

# Block off access to admin and devel - just in case
<LocationMatch "/(admin|devel)">
    Order deny,allow
#    Include conf.d/ip.conf
# including the line above always caused an error when re-starting apache2 so I have hard coded the IPs below (these are not the ones I am usinb obviously!)
Allow from 123.123.123.123
Allow from 124.124.124.124
    Deny from all
</LocationMatch>
#============================================================

/etc/apache2/conf.d/ip.conf:

#============================================================
#This file always caused a problem when repstarting apache so I hard coded the IP addresses
# into the drupal6.conf file.  Would like to undersatand why this wont work! I am using the correct IP addresses, these are just for posting!
Allow from 123.123.123.123
Allow from 124.124.124.124
#============================================================

/etc/apache2/apache2.conf:

#============================================================
# ..
# ..
# All the apache config and at the very bottom is these lines:
# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/[^.#]*
#============================================================

/etc/apache2/sites-available/drupalsites.conf:

#============================================================
# This is called from Apache2.conf
# Each vhost can be read in as its own file
Include vhosts/mywebsite.conf
#============================================================

/etc/apache2/vhosts/mywebsite.conf:

#============================================================
# This is called from /etc/apache2/sites-available/drupalsites.conf
<VirtualHost mywebsite.co.uk:80>
DocumentRoot /home/d/r/drupal/web/public_html
ServerName mywebsiteco.uk
ServerAlias www.mywebsiteco.uk
ErrorLog /var/log/apache2/sites/mywebsite.co.uk_error-log
CustomLog /var/log/apache2/sites/mywebsite.co.uk_access-log "combined"

# Rewrite the www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.co.uk/?$ [NC]
RewriteRule ^(.*)$ http://mywebsite.co.uk$1 [L,R=301]

# Read in the drupal configuration
Include conf.d/drupal6.conf

# Block access while developing
#  Include conf.d/beta.conf

</VirtualHost>
#============================================================

在 /etc/hosts 中:

127.0.0.1 localhost server0
127.0.0.1 mywebsite.co.uk
123.123.123.123 myservername.co.uk

我创建的网站根目录为:

/home/m/y/mysite/web/public_html

我已将物理 public_html 目录替换为指向

/home/d/r/drupal/web/public_html

我可以查看文本文件,例如 www.mysite.co.uk/INSTALL.txt,但是当我尝试查看任何 php 页面(例如 install.php 或根目录)时,我总是收到以下错误:“内部服务器错误,这是您的脚本错误,请检查您的错误日志以获取更多信息。”

我不知道下一步该做什么,如果能得到任何帮助或建议我将非常感激。

谢谢

答案1

您发布的配置比实际需要的要复杂得多。我不太清楚为什么要这样设置,但我确实注意到一些可能会产生影响的事情。

首先,在 drupal6.conf 中全部您需要的是以下内容:

<Directory /home/d/r/drupal/web/public_html/>
    Options +FollowSymLinks
    AllowOverride All
    order allow,deny
    allow from all
</Directory>

其余的东西都是次要的,可能会使问题复杂化(或导致问题)。我建议——尤其是对于初始安装——尽可能简化配置。我运行了一个很多Drupal 站点,除了将 mysite.conf 指向 Drupal 目录并创建 (Drupal root)/sites/my.site.com 目录和设置文件之外,我从未做过任何改动。

我建议从 drupal6.conf 中删除所有其他内容,然后查看它是否适用于安装。然后重新添加 /admin、install.php 等上的访问块。我不建议弄乱配置文件中的 .htaccess 文件。在 apache 配置中省略包含 .htaccess 的行,只需让 .htaccess 按照 apache 的设计进行选择即可。

答案2

出于好奇,您是否已启用 php 并在某处设置了适当的 AddHandler 行?它看起来有点像尝试直接将 php 文件作为 cgi 脚本运行,而不是使用模块。在 Ubuntu 和 Debian 上,您可以使用以下命令确保 php 作为模块加载:

a2enmod php5
/etc/init.d/apache2 force-reload

如果 php 在您的设置中的其他地方运行正常,我也会倾向于检查 .htaccess 文件。具体来说,您需要确保它没有尝试将 .php 文件明确设置为作为 cgi 脚本运行。如果您发现任何类似以下行的内容引用 .php 文件,请将其注释掉,看看情况是否有所改善。

AddHandler cgi-script .php

由于您已明确加载了 .htaccess 文件,请不要忘记根据需要重新加载。

相关内容