Apache 虚拟主机 VirtualHost 配置

转自:http://www.neoease.com/apache-virtual-host/

Windows 是市场占有率最高的 PC 操作系统, 也是很多人的开发环境. 其 VirtualHost 配置方法与 Linux 上有些差异, 以下方式适合原生 Apache, XAMPP 和 WAMP 套件.

1. 打开目录 {Apache2 安装目录}confextra\, 找到 httpd-vhosts.conf 文件.

2. 仿照例子, 添加一段代码来指定某一域名的网站.

#
# DocumentRoot 是网站文件存放的根目录
# ServerName 是网站域名, 需要跟 DNS 指向的域名一致
#
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "D:/workspace/php/demo_neoease_com"
    ServerName demo.neoease.com
    ErrorLog "logs/demo.neoease.com-error.log"
    CustomLog "logs/demo.neoease.com-access.log" common
</VirtualHost>

3. 打开 httpd.conf 文件, 添加如下语句.

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

4. 重启 Apache 服务.

注:默认情况下新添加的虚拟主机的的路径是没有访问权限的,添加路径的访问的权限

例如:

<Directory "E:/Apache2.2/www.ee.com">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

原文地址:https://www.cnblogs.com/ribavnu/p/3489884.html