关于apache 的多端口,多域名的设置网上介绍的太复杂,我相信很多人和我一样都看的不太懂吧,本人花了点时间总结出来,就这么几步.(以Wampserver 中的apache为例)
打开httpd.conf文件(这个应该懂吧!)
1.设置需要开启的监听端口.
Listen 80
Listen 8080
2.设置虚拟端口
NameVirtualHost *:80
NameVirtualHost *:8080
3.这里设置3个虚拟目录 (红色部分就是你网站的目录,其他看不懂的不用管它)
<Directory "D:\wamp\www\aaa">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "D:\wamp\www\bbb">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "D:\wamp\www\ccc">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
4.配置虚拟目录对应的域名或端口(假如aaa.com, bbb.com, ccc.com 的IP:127.0.0.1)
<VirtualHost *:80> ----当访问www.aaa.com时就转到 aaa这个虚拟目录
DirectoryIndex index.html index.php
ServerName "www.aaa.com"
DocumentRoot "D:\wamp\www\aaa"
</VirtualHost>
<VirtualHost *:8080> ----当访问www.aaa.com:8080时就转到 bbb这个虚拟目录
DirectoryIndex index.html index.php
ServerName "www.aaa.com:8080"
DocumentRoot "D:\wamp\www\ bbb "
</VirtualHost>
<VirtualHost *:80> ----当访问www.ccc.com时就转到 ccc这个虚拟目录
DirectoryIndex index.html index.php
ServerName "www.ccc.com"
DocumentRoot "D:\wamp\www\ccc"
</VirtualHost>
结束...................