1配置apache支持虚拟主机。这一步很重要。apache
#Include conf/extra/httpd-vhosts.confwindows
找到 上面相关文本,去掉#Include conf/extra/httpd-vhosts.conf前的#。ide
保存退出spa
2编辑conf目录下extra文件夹下的httpd-vhosts.conf。如例子所示.net
<VirtualHost *:80>get
ServerAdmin 8@1.comio
DocumentRoot "D:/Web/apache/htdocs"配置
ServerName www.gs.cn:80im
ServerAlias www.gs.cn:80error
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin kuhool.com
DocumentRoot "F:/Web1"
ServerName www.kuhool.com
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
<Directory "F:/Web1">
AllowOverride None
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
3编辑本地host文件,以windows为例
进入C:/Windows/System32/drivers/etc
记事本打开hosts文件
最后添加
127.0.0.1 localhost
127.0.0.1 www.kuhool.com
4注意 若是报403错误 请针对他作修改
<Directory "F:/Web1">
AllowOverride None
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>