Apache有多个站点,一个站点有效,其他站点无效

我已经尝试了类似问题的所有方法,但是没有运气。

我收到“您无权访问此服务器上的X”。在所有请求上。

我在同一IP上有两个站点,apache配置文件是相同的,文件权限是相同的,但是,一个有效而另一个却不一样。

配置文件:

<VirtualHost x.x.xxx.xx:80>
    ServerName site2.example.com
    ServerAlias site2.example.com
    Redirect / https://site2.example.com/

    <IfModule mod_security2.c>
            SecRuleEngine Off
        </IfModule>
</VirtualHost>

<VirtualHost x.x.xxx.xx:443>
    Protocols h2 http/1.1
    ServerName site2.example.com
    ServerAlias site2.example.com
    ServerAdmin it@example.com

    SetEnv ENVironMENT production

    DocumentRoot /data/www/site2.example.com
    <Directory /data/www/site2.example.com>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        AddOutputFilterByType DEflaTE text/html text/plain text/xml text/css text/javascript application/javascript
        Require all granted
    </Directory>

    <IfModule mod_security2.c>
        SecRuleEngine Off
    </IfModule>

    ErrorLog /var/log/apache2/site2_error.log
    LogLevel warn

    KeepAlive On

    SSLEngine On
    SSLCertificateFile /etc/letsencrypt/live/site2.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/site2.example.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf

    Header add strict-transport-security "max-age=15768000"

    # Add File Caching
    <filesMatch ".(js|css|png|jpeg|jpg|gif|ico|pdf)$">
        Header set Cache-Control "max-age=31536000,public"
    </filesMatch>

    # Disable slower encryption on older versions of IE
    SetEnvIf User-Agent ".*MSIE [1-5].*" \
          nokeepalive ssl-unclean-shutdown \
          downgrade-1.0 force-response-1.0

    SetEnvIf User-Agent ".*MSIE [6-9].*" \
          ssl-unclean-shutdown
</VirtualHost>

我可能会缺少什么?

使用的权限命令:

  • sudo chown -R www-data:www-data /data/www/site2.example.com
  • sudo find /data/www/site2.example.com -type f -exec chmod 644 {} \;
  • sudo find /data/www/site2.example.com -type d -exec chmod 775 {} \;

我已经重新启动了Apache。

jacky598 回答:Apache有多个站点,一个站点有效,其他站点无效

也许问题不在于配置。许多其他修饰符(包括.htaccess)都会影响服务器响应。

要找出问题所在,请使用失败的网站配置文件,但使用有效的网站目录路径,查看其是否有效。

,

所以问题在于,对于SSL,没有使用上述配置文件。通过列出启用的sudo apache2ctl -S返回以下内容的网站,我发现了问题:

port 443 namevhost site2.example.com (/etc/apache2/sites-enabled/site2-le-ssl.conf:2)

哪个是设置letencrypt时创建的文件。我通过禁用配置文件sudo a2dissite site2-le-ssl.conf解决了该问题。

本文链接:https://www.f2er.com/3166490.html

大家都在问