VPS中APACHE服务器多站点配置
打开bin\apache\Apache2.2.17\conf\httpd.conf
第61行:LoadModule alias_module modules/mod_alias.so 前面是否有#,如果有,去除这句话前面的# (开启alias的支持)
第446行:#Include conf/extra/httpd-vhosts.conf 去掉前面的# (使apache能够读取extra/httpd-vhosts.conf 文件)
打开bin\apache\Apache2.2.17\conf\extra\httpd-vhosts.conf
删除底部默认的一些配置:
?
之后根据下述添加多站点的方式,选择一种自己进行添加:
1、多IP多端口多站点配置
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
<VirtualHost 172.20.30.40:80>
DocumentRoot /www/example1-80
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
DocumentRoot /www/example1-8080
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.50:80>
DocumentRoot /www/example2-80
ServerName www.example1.org
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
DocumentRoot /www/example2-8080
ServerName www.example2.org
</VirtualHost>
————————————————————
2、多IP单端口多站点
———————————————————–
<VirtualHost 192.168.1.1:80>
DocumentRoot "/usr/local/apache/a"
ServerName www.a.com #网站根目录
ServerAlias a.com #做出响应的域名,其实也就是这里列出的域名,也指向前面设置的网站根目录
DirectoryIndex index.html index.php
</VirtualHost>
NameVirtualHost 192.168.1.2:80
<VirtualHost 192.168.1.2:80>
DocumentRoot "/usr/local/apache/b"
ServerName www.b.com
ServerAlias b.com