配置步骤如下:
1.在硬盘中建立一个虚拟主机的目录,如“D:/wamp/www/jockie”;
2.打开PHP配置文件apache/apache2.4.9/conf/httpd.conf,打开虚拟主机引用文件(也就是去掉前面的注释符号):
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
3.打开虚拟主机配置文apache/apache2.4.9/conf/extra/httpd-vhosts.conf,添加你需要的主机,需要几个就配置几个,这里我只配置了一个:
需要注意的是,监听的端口为apache的端口
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot
"d:/wamp/www/jockie"
ServerName www.jockie.com
ErrorLog
"logs/www.jockie.com-error.log"
CustomLog
"logs/www.jockie.com-access.log" common
</VirtualHost>
4.绑定域名IP,在C:/windows/system32/drivers/etc/host配置,如:
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 www.jockie.com
5.重启apache,到此大功告成了吗?你肯定想多了,你可以去访问一下http://www/jockie.com 当然这个你肯定可以访问,就是你的虚拟主机。但是你再去试试localhost/zmitwx/index.php 这个你就不能访问了,解决办法是:打开虚拟主机配置文apache/apache2.4.9/conf/extra/httpd-vhosts.conf,添加localhost
<VirtualHost *:80>
ServerAdmin
[email protected]
DocumentRoot
"d:/wamp/www"
ServerName localhost
ErrorLog
"logs/dummy-host.localhost-error.log"
CustomLog "logs/dummy-host.localhost-access.log"
common
</VirtualHost>
6.最后再重启apache,localhost/zxj/index.php
及 www/jockie.com 都可以访问了。
本人qq:617324031 欢迎交流。