[英]Apache moving to virtual hosts
Hoping to get some guidance with a move from a single apache/website per machine to a multiple virtual host setup per machine.希望从每台机器的单个 apache/网站转移到每台机器的多个虚拟主机设置时获得一些指导。
Current setup: LAMP stack with software packages installed from source code: Apache 2.4.2, php 5.4.3 and mysql 5.1.63 For the current single site (site1.ie) setup I have the virtualhost details, DocumentRoot and Directory directive pointing to site1 documentroot for the current site in the httpd.conf.当前设置:带有从源代码安装的软件包的 LAMP 堆栈:Apache 2.4.2、php 5.4.3 和 mysql 5.1.63 对于当前的单站点 (site1.ie) 设置,我有虚拟主机详细信息、DocumentRoot 和 Directory 指令指向httpd.conf 中当前站点的 site1 documentroot。
To enable virtual hosts I have uncommented the Include conf/extra/httpd-vhosts.conf and I have moved the virtualhost site config details into the httpd-vhosts.conf.为了启用虚拟主机,我取消了 Include conf/extra/httpd-vhosts.conf 的注释,并将虚拟主机站点配置详细信息移到 httpd-vhosts.conf 中。 Something like this:
像这样的东西:
<VirtualHost _default_:443>
ServerName http://site1.ie
DocumentRoot "/usr/local/apache2/htdocs/site1"
ServerAlias site1.ie
</VirtualHost>
When I uncomment the DocumentRoot details in the httpd.conf file and restart httpd I get a 403 forbidden error when I try to load site1.ie.当我取消注释 httpd.conf 文件中的 DocumentRoot 详细信息并重新启动 httpd 时,我在尝试加载 site1.ie 时收到 403 forbidden 错误。
Directory directive in the httpd-vhosts.conf (moved from httpd.conf): httpd-vhosts.conf 中的目录指令(从 httpd.conf 移出):
<Directory "/usr/local/apache2/htdocs/site1">
Options Indexes FollowSymLinks
AllowOverride AuthConfig
Require all granted
</Directory>
EDIT:编辑:
The error_log in httpd gave this error: AH01630: client denied by server configuration: /usr/local/apache2/htdocs/ httpd 中的 error_log 给出了这个错误:AH01630:客户端被服务器配置拒绝:/usr/local/apache2/htdocs/
This is the location of the website data is it controlled by this Directory directive:这是网站数据的位置是否由该目录指令控制:
<Directory />
AllowOverride none
Require all denied
</Directory>
As far as I know this is the default to deny access to this folder but allow access to its subfolders through Directory directives of their own?据我所知,这是拒绝访问此文件夹但允许通过自己的目录指令访问其子文件夹的默认设置?
The point at which the 403 issue occurs is when I comment out the DocumentRoot in the main httpd.conf file and define the DocumentRoot inside the virtualhost directive (either in the httpd.conf file or the httpd-vhosts.conf file).发生 403 问题的点是当我注释掉主 httpd.conf 文件中的 DocumentRoot 并在 virtualhost 指令(在 httpd.conf 文件或 httpd-vhosts.conf 文件中)定义 DocumentRoot 时。
I temporarily changed the Directory / directive (shown above) to Require all granted and this got rid of the 403 error but all I was presneted with is the default apache 'It works' page.我暂时将目录/指令(如上所示)更改为 Require all allowed ,这消除了 403 错误,但我所使用的只是默认的 apache 'It works' 页面。 I still was unable to access the defined documentroot directory for site1.
我仍然无法访问为 site1 定义的 documentroot 目录。
Would anyone have any pointers on what I am doing wrong?有人会指出我做错了什么吗?
I believe your tags need to be inside the vhosts file inside the tags in order for it to work, since you've enabled virtual hosting inside your httpd.conf file, such as:我相信您的标签需要位于标签内的 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>
Also consider adding variables to httpd.conf so you can adjust in one location, like so:还可以考虑向 httpd.conf 添加变量,以便您可以在一个位置进行调整,如下所示:
Define INSTALL_DIR d:/wamp64
Define SRVRPATH ${INSTALL_DIR}/usr/local/apache2/htdocs
Which will allow you to change the first code block above from这将允许您更改上面的第一个代码块
DocumentRoot "/usr/local/apache2/htdocs/site1"
<Directory "/usr/local/apache2/htdocs/site1">
To到
DocumentRoot "${SRVRPATH}/site1"
<Directory "${SRVRPATH}/site1">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.