[英]Apache VirtualHost configure
After I configured virtual host, my apache document root changed to the virtual host's document root, I just want to know why. 配置虚拟主机后,我的apache文档根目录更改为虚拟主机的文档根目录,我只想知道为什么。
here is my httpd-vhosts.conf: 这是我的httpd-vhosts.conf:
<VirtualHost *:80>
ServerName myapp.zend
DocumentRoot /opt/lampp/htdocs/php_zend_projects/myapp
<Directory /opt/lampp/htdocs/php_zend_projects/myapp/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
</VirtualHost>
After I restart apache server, localhost page changed to index of /opt/lampp/htdocs/php_zend_projects/myapp
, 重新启动apache服务器后,本地主机页面更改为/opt/lampp/htdocs/php_zend_projects/myapp
索引,
http://gwjyhs.com/t6/702/1556725814x2728329017.png http://gwjyhs.com/t6/702/1556725814x2728329017.png
but it is supposed to be xampp's default page like this: 但它应该是xampp的默认页面,如下所示:
http://gwjyhs.com/t6/702/1556726269x2728278877.png http://gwjyhs.com/t6/702/1556726269x2728278877.png
If you enable vhosts you have to add an entry that looks like: 如果启用虚拟主机,则必须添加如下所示的条目:
<VirtualHost *:80>
DocumentRoot "F:/Dev/xampp/htdocs"
ServerName localhost
</VirtualHost>
Note: change path to whatever is appropriate for you. 注意:将路径更改为适合您的内容。
Restart webserver and it should work as before. 重新启动网络服务器,它应该像以前一样工作。
Reasoning behind this can be found in a comment on top of the httpd-vhosts.conf
: 可以在httpd-vhosts.conf
顶部的注释中找到其背后httpd-vhosts.conf
:
The first VirtualHost section is used for all requests that do not match a ##ServerName or ##ServerAlias in any block. 第一个VirtualHost部分用于所有与任何块中的## ServerName或## ServerAlias不匹配的请求。
That means when you type in localhost
it fallbacks to your myapp.zend
vhost because it is (probably) the first virtualhost section. 这意味着当您键入localhost
它回myapp.zend
虚拟主机,因为它(可能)是第一个virtualhost部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.