【问题标题】:Apache moving to virtual hostsApache 迁移到虚拟主机
【发布时间】:2014-08-06 11:56:29
【问题描述】:

希望从每台机器的单个 apache/网站转移到每台机器的多个虚拟主机设置中获得一些指导。

当前设置:带有从源代码安装的软件包的 LAMP 堆栈: Apache 2.4.2、php 5.4.3 和 mysql 5.1.63 对于当前的单个站点 (site1.ie) 设置,我在 httpd.conf 中有指向当前站点的 site1 documentroot 的虚拟主机详细信息、DocumentRoot 和 Directory 指令。

为了启用虚拟主机,我取消了 Include conf/extra/httpd-vhosts.conf 的注释,并将虚拟主机站点配置详细信息移至 httpd-vhosts.conf。像这样的:

<VirtualHost _default_:443>
ServerName http://site1.ie
DocumentRoot "/usr/local/apache2/htdocs/site1"
ServerAlias site1.ie
</VirtualHost>

当我取消注释 httpd.conf 文件中的 DocumentRoot 详细信息并重新启动 httpd 时,我在尝试加载 site1.ie 时收到 403 禁止错误。

httpd-vhosts.conf 中的目录指令(从 httpd.conf 移出):

<Directory "/usr/local/apache2/htdocs/site1">
    Options Indexes FollowSymLinks
    AllowOverride AuthConfig
    Require all granted
</Directory>

编辑:

httpd 中的 error_log 给出了这个错误:AH01630: client denied by server configuration: /usr/local/apache2/htdocs/

这是网站数据的位置,是否受此目录指令控制:

<Directory />
    AllowOverride none
    Require all denied
</Directory>

据我所知,这是默认拒绝访问此文件夹但允许通过其自己的目录指令访问其子文件夹的默认设置?

发生 403 问题的地方是我在主 httpd.conf 文件中注释掉 DocumentRoot 并在 virtualhost 指令中定义 DocumentRoot(在 httpd.conf 文件或 httpd-vhosts.conf 文件中) .

我暂时将目录/指令(如上所示)更改为要求所有已授予,这消除了 403 错误,但我所使用的只是默认的 apache 'It works' 页面。我仍然无法访问为 site1 定义的 documentroot 目录。

有人能指点我做错了什么吗?

【问题讨论】:

  • 检查日志以查看实际请求的文件。这将帮助您确定 Root 是否错误或 perms 是否错误。
  • httpd 中的 error_log 给出了这个错误:AH01630: client denied by server configuration: /usr/local/apache2/htdocs/

标签: apache ubuntu permissions virtualhost document-root


【解决方案1】:

我想你会在this site找到答案。

这是可能导致问题的清单。

【讨论】:

    【解决方案2】:

    我相信您的标签需要在标签内的 vhosts 文件中才能正常工作,因为您已在 httpd.conf 文件中启用虚拟主机,例如:

    <VirtualHost *:443>
        ServerName site1.ie
        ServerAlias site1.ie
        DocumentRoot "/usr/local/apache2/htdocs/site1"
        <Directory "/usr/local/apache2/htdocs/site1">
            Options Indexes FollowSymLinks
            AllowOverride AuthConfig
            Require all granted
        </Directory>
    </VirtualHost>
    

    还可以考虑在 httpd.conf 中添加变量,以便您可以在一个位置进行调整,如下所示:

    Define INSTALL_DIR d:/wamp64
    Define SRVRPATH ${INSTALL_DIR}/usr/local/apache2/htdocs
    

    这将允许您更改上面的第一个代码块

        DocumentRoot "/usr/local/apache2/htdocs/site1"
        <Directory "/usr/local/apache2/htdocs/site1">
    

        DocumentRoot "${SRVRPATH}/site1"
        <Directory "${SRVRPATH}/site1">
    

    【讨论】:

      猜你喜欢
      • 2017-03-04
      • 1970-01-01
      • 1970-01-01
      • 2011-06-19
      • 2019-08-25
      • 2012-04-26
      • 2012-09-25
      • 2011-03-25
      • 2018-06-26
      相关资源
      最近更新 更多