简体   繁体   English

Apache VirtualHost配置

[英]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.

相关问题 使用Virtualhost在Apache中配置SSL - Configure Ssl in Apache With Virtualhost Vagrant Chef配置并激活apache2 virtualhost - Vagrant Chef configure and activate apache2 virtualhost 是否可以在同一VirtualHost下配置多个Apache WSGIAlias? - Is it possible to configure multiple Apache WSGIAlias'es under same VirtualHost? 如何在具有别名的虚拟主机上配置 Apache 以将 HTTP 重定向到 HTTPS? - How to configure Apache to redirect HTTP to HTTPS on a virtualhost that have an alias? 如何在 Apache 中正确配置 VirtualHost(用于 eXist-db 应用程序) - How to configure VirtualHost in Apache properly (used for eXist-db app) 如何配置多个 <virtualhost> 使用相同的SSL证书-Apache - How can I configure multiple <virtualhost> with the same SSL Certificate - Apache 如何在本地机器中为多个虚拟主机配置linux / apache - How to configure linux/apache for multiple virtualhost in local machine 在Apache服务器中配置基于端口的虚拟主机时,我犯了什么错误? - What is my mistake in configure port based virtualhost in Apache server? apache VirtualHost重定向到其他VirtualHost - apache VirtualHost redirecting to different VirtualHost CentOS Apache VirtualHost默认 - CentOS Apache VirtualHost default
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM