Wampserver: 配置 Apache 虚拟机

  1. 确保 httpd.conf 配置文件,已将引入虚拟机配置打开

Include conf/extra/httpd-vhosts.conf

  1. 打开 extra/httpd-vhosts.conf,添加上需要添加的 virtualhost

<VirtualHost *:80>
ServerName www.saiku.cc
DocumentRoot D:\workspances
<Directory "D:\workspances">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

  1. How the server selects the proper name-based virtual host .

服务器如何选择合适的"name-based virtual host"。
#3.1 It is important to recognize that the first step in name-based virtual host resolution is IP-based resolution.
首先要知道 name-base virtual host 解决方案的第一步,就是通过 IP-based来解决的。
Name-based virtual host resolution only chooses the most appropriate name-based virtual host after narrowing down the candidates to the best IP-based match. Using a wildcard (*) for the IP address in all of the VirtualHost directives makes this IP-based mapping irrelevant.
#3.2 name-base virtual host 在将匹配范围缩小,直到匹配到最准确的 IP。在所有的 VirtualHost 指令中,使用通配符(*)作为 IP 地址,将会使 IP-based 匹配失效。
When a request arrives, the server will find the best (most specific) matching [<VirtualHost>](http://httpd.apache.org/docs/2.4/en/mod/core.html#virtualhost) argument based on the IP address and port used by the request.
#3.3 当一个请求到达时,服务器会以发起请求的 IP 地址和端口为基础,找到匹配度最高的参数。
If there is more than one virtual host containing this best-match address and port combination, Apache will further compare the [ServerName](http://httpd.apache.org/docs/2.4/en/mod/core.html#servername)
and [ServerAlias](http://httpd.apache.org/docs/2.4/en/mod/core.html#serveralias)
directives to the server name present in the request.
#3.4 如果存在多个虚拟机,都包含了匹配的 IP 地址与端口组合,Apache 会进一步比较 ServerName 指令、ServerAlias 指令与请求中发送的 server name。
If you omit the [ServerName](http://httpd.apache.org/docs/2.4/en/mod/core.html#servername)
directive from any name-based virtual host, the server will default to a fully qualified domain name (FQDN) derived from the system hostname. This implicitly set server name can lead to counter-intuitive virtual host matching and is discouraged.
#3.5 如果你在任一个 name-based virtual host 中,都没使用 ServerName 指令,服务器默认会使用来自系统 hostname 的全域名。这种隐藏的 server name 设置会导致反直觉的 host 匹配,不鼓励这种做法。
详情参考,官方手册地址

  1. Windows 测试虚拟机配置命令,进入到 /apache_install_path/to/bin/

httpd.exe -S

  1. Check httpd.conf syntax | 检查配置文件的语法,截图如下:


    check_httpdconf_syntax.png

提示:

<Directory "F:\projects\trunk"> path is invalid.

** httpd-vhosts.conf ** 配置内容:

<VirtualHost *:80>
ServerName www.saiku.cc
DocumentRoot F:\projects\trunk
<Directory "F:\projects\trunk">
#<Directory "D:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 7,952评论 0 0
  • 一、Nagios简介 Nagios是一款开源的电脑系统和网络监视工具,能有效监控Windows、Linux和Uni...
    1b3bd36d9d21阅读 12,551评论 3 13
  • =========================================================...
    lavor阅读 8,842评论 0 5
  • 00 序言 本文集专收录平日遐思,记录生活琐事。尽量避免空泛感慨和缥缈情怀,就是一本接地气的日记册子,不要美,要真...
    脊生阅读 1,911评论 1 1
  • 做线上赛的时候遇见了一道题, 题目:访问http://140.143.191.241:8081,获得服务器根目录下...
    Sund4y阅读 5,241评论 0 2