dd

【详解】如何配置apache2.x虚拟主机

jerry PHP 2015年08月10日 收藏

在httpd.conf中,找到行

Include "conf/extra/httpd-vhosts.conf"

去掉前面的#号。

需改httpd-vhosts.conf这个文件如下

#############################################################
# 
# @author        liushengxu
# @date          2015-01-01
# @description   This virtual host is use to demo
# 
#############################################################
NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "D:/phpxm/mbsucai"
    ServerName www.jianzhan.love
    ServerAlias www.jianzhan.love jianzhan.love
    <Directory "D:/phpxm/mbsucai">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
    ErrorLog "D:/phpxm/mbsucai/error.log"
    CustomLog "D:/phpxm/mbsucai/access.log" combined
</VirtualHost>

注意 

Require all granted

这句是这apache2.4里配置的(不配置的话会出现 Forbidden You don't have permission to access / on),apache2.2不需要配置。


最后打开C:\Windows\System32\drivers\etc\hosts这个文件在最后添加下信息

127.0.0.1 www.jianzhan.love
127.0.0.1 jianzhan.love

重启apache即可。

dd