apache:一个ip绑定多个域名的问题
基于IP的虚拟主机使用连接的IP地址来决定相应的虚拟主机。这样,你就需要为每个虚拟主机分配一个独立的IP地址。而基于域名的虚拟主机是根据客户端提交的HTTP头中标识主机名的部分决定的。使用这种技术,很多虚拟主机可以共享同一个IP地址
[*]基于IP的虚拟主机,通过端口区分:
1、httpd.conf启动虚拟主机的配置
2、配置httpd-vhosts添加虚拟主机监听端口为80
DocumentRoot "" #第一个网站的根目录
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
添加另一个虚拟主机,假设监听81端口
DocumentRoot "" #第二个网站的根目录
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
3、在httpd-vhosts(建议)注销默认的DocumentRoot
4、在htttpd.conf让apache监听其他端口如81
5、在hosts文件添加多对ip和域名的对应关系
C:/window/system32/drivers/etc/hosts
6、重启apache
[*]基于域名的虚拟主机,通过ServerName区分域名
1、httpd.conf启动虚拟主机的配置
2、配置httpd-vhosts
DocumentRoot "" #网站的根目录
ServerName www.xxxxxx.com #修改此处
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
3、在hosts文件添加多对ip和域名的对应关系
4、重启apache
详情可以查看我的另外一篇:http://www.iyunv.com/mackxu/archive/2012/04/10/2439917.html
页:
[1]