在Apache目录下的 httpd.conf中修改代码:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf <把这行前面的#号去掉,才可以创建虚拟主机>
D:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf 中添加:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.a.com
DocumentRoot "d:/Program Files/Apache Software Foundation/Apache2.2/htdocs/zhangzhiliang"
ServerName zhangzhiliang.com
ErrorLog "logs/dummy-host2.a.com-error.log"
CustomLog "logs/dummy-host2.a.com-access.log" common
</VirtualHost>
注释:我在d:/Program Files/Apache Software Foundation/Apache2.2/htdocs 下创建了文件夹:zhangzhiliang.
如果在zhangzhiliang文件夹下创建了个hello.php文件,在浏览器可以这样访问:
zhangzhiliang.com/hello.php