php多虚拟主机配置
一、配置httpd.conf
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf //取消这一行的#
二、配置httpd-vhosts.conf文件
1.多IP模式
<VirtualHost *:80>
DocumentRoot "E:/www/htdocs" //虚拟主机文件夹
ServerName 127.0.0.1 //访问IP地址
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:/www/htdocsA"
ServerName 127.0.0.2
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:/www/htdocsB"
ServerName 127.0.0.3
</VirtualHost>
2.多站点设置
<VirtualHost *:80>
DocumentRoot "E:/www/htdocs" //虚拟主机文件夹
ServerName www.a.com //访问的域名
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:/www/htdocsA"
ServerName www.b.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:/www/htdocsB"
ServerName www.c.com
</VirtualHost>
3.多端口
<VirtualHost *:8080>
DocumentRoot "E:/www/htdocs" //虚拟主机文件夹
ServerName 127.0.0.1 //访问的IP及端口
</VirtualHost>
<VirtualHost *:8081>
DocumentRoot "E:/www/htdocsA"
ServerName 127.0.0.1
</VirtualHost>
<VirtualHost *:8082>
DocumentRoot "E:/www/htdocsB"
ServerName 127.0.0.1
</VirtualHost>
三、修改windows系统下的C:\Windows\System32\drivers\etc\hosts文件(需要管理员身份,不然无法修改)
# IP Hosts
127.0.0.1 localhost
127.0.0.1 bookstore
127.0.0.1 diaryfood