希望通过从每台机器的单个apache /网站迁移到每台机器的多个虚拟主机设置来获得一些指导。
当前设置:LAMP堆栈,其中包含从源代码安装的软件包:Apache 2.4.2,PHP 5.4.3和MySQL 5.1.63对于当前的单个站点(site1.ie)设置,我在httpd.conf中具有虚拟主机详细信息,DocumentRoot和Directory指令,它们指向当前站点的site1 documentroot。
为了启用虚拟主机,我已取消注释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:服务器配置拒绝了客户端:/ usr / local / apache2 / htdocs /
这是此目录指令控制的网站数据位置:
<Directory />
AllowOverride none
Require all denied
</Directory>
据我所知,这是默认设置:拒绝访问此文件夹,但允许通过其自身的Directory指令访问其子文件夹?
发生403问题的时候是,当我在主httpd.conf文件中注释掉DocumentRoot并在virtualhost指令(在httpd.conf文件或httpd-vhosts.conf文件中)内定义DocumentRoot时。
我暂时将目录/指令(如上所示)更改为要求所有被授予,这摆脱了403错误,但我所能预见的是默认的apache'It works'页面。我仍然无法访问site1的已定义documentroot目录。
有人会指出我在做什么错吗?
我想您会在this site上找到答案。
这是可能引起您问题的事物的清单。
我相信您的标签需要位于标签内的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">