Apache2 403 错误与多个虚拟主机

Apache2 403 错误与多个虚拟主机

我的 Apache2 安装遇到一些问题。

上周由于硬盘故障,我进行了常规备份,将硬盘换成了新硬盘,并重新安装了所有 SO(Debian 7 AMD64)和 Apache2。我已将所有数据从备份恢复到新磁盘。

我再次配置了虚拟主机,其配置与上次安装相同,但这次我尝试访问除仅托管静态内容的虚拟主机之外的任何虚拟主机。

Apache 错误文件上没有错误,Apache 启动期间也没有错误或警告。我还检查了文件系统的权限和所有者。

这是我的配置文件:

apache2.conf

ServerRoot "/etc/apache2"

LockFile ${APACHE_LOCK_DIR}/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5

<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

<IfModule mpm_event_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

AccessFileName .htaccess

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>

DefaultType None
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel debug
Include mods-enabled/*.load
Include mods-enabled/*.conf
Include ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
 LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
 LogFormat "%h %l %u %t \"%r\" %>s %O" common
 LogFormat "%{Referer}i -> %U" referer
 LogFormat "%{User-agent}i" agent
 Include conf.d/
 Include httpd.conf

httpd配置文件

<VirtualHost x.x.x.x:80>
        DocumentRoot /home/www/hostname.domain.tld
        ServerName hostname.domain.tld
        ServerAdmin [email protected]

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /home/www/hostname.domain.tld>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

<VirtualHost x.x.x.x:80>
        DocumentRoot /home/www/static.domain.tld
        ServerName static.domain.tld
        ServerAdmin [email protected]

        <Directory /home/www/static.domain.tld>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

<VirtualHost x.x.x.x:80>
        DocumentRoot /home/www/mail.anijapan.com
        ServerName mail.domain.tld
        ServerAdmin [email protected]

        <Directory /home/www/mail.domain.tld>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

<VirtualHost x.x.x.x:80>
        DocumentRoot /home/www/bugs.domain.tld
        ServerName bugs.domain.tld
        ServerAdmin [email protected]

        <Directory /home/www/bugs.domain.tld>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

端口配置文件

NameVirtualHost x.x.x.x:80
Listen 80

<IfModule mod_ssl.c>
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

我尝试过不同的方法,在 Google 等处搜索,但都没有任何结果。

有人知道我的问题吗?

谢谢!

答案1

像这样启动apache,前台+调试,如果由于某种原因它无法写入日志,它将以这种方式启动。

. /etc/apache2/envvars
apache2 -e debug -DFOREGROUND

另一个建议是查看 /var/log/messages 和 /var/log/syslog,但你可能已经这样做了。更多信息请见此页面zroger.com

答案2

我终于让 Apache 正常工作,不再出现 403 错误。403 错误的原因很简单,不是服务器的问题。

对于域名 DNS 管理,我使用 CloudFlare。为了在服务器硬盘更换期间提供服务,我将所有网站移至另一台具有新 IP 的服务器。在新的硬盘上安装操作系统后,我将网站从救援服务器移至新磁盘,并在 CloudFlare 上将 DNS 记录的 IP 更改为旧 IP,但 CloudFlare 在此处失败,因为它们不会通过内部错误传播新 IP 地址。我看到制作跟踪路由(非常愚蠢但有效的解决方案)以查看 A 记录的真实最终目的地,而不是 CloudFlare 上显示的最终目的地。

为了让 CloudFlare 使用正确的 A 记录,我删除了它,保存了更改,然后将 A 记录添加到正确的 IP 地址。一旦我这样做,一切就开始正常工作了。

相关内容