首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > Apache >

VPS中APACHE服务器多站点配备

2012-07-08 
VPS中APACHE服务器多站点配置打开bin\apache\Apache2.2.17\conf\httpd.conf第61行:LoadModule alias_modul

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:80Listen 172.20.30.40:8080Listen 172.20.30.50:80Listen 172.20.30.50:8080
<VirtualHost 172.20.30.40:80>DocumentRoot /www/example1-80ServerName www.example1.com</VirtualHost>
<VirtualHost 172.20.30.40:8080>DocumentRoot /www/example1-8080ServerName www.example1.com</VirtualHost>
<VirtualHost 172.20.30.50:80>DocumentRoot /www/example2-80ServerName www.example1.org</VirtualHost>
<VirtualHost 172.20.30.50:8080>DocumentRoot /www/example2-8080ServerName 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.comServerAlias b.comDirectoryIndex index.php</VirtualHost>
<VirtualHost 192.168.1.2:80>DocumentRoot "/usr/local/apache/c"ServerName www.c.comServerAlias c.comDirectoryIndex index.php</VirtualHost>—————————————————————
3、单IP单端口多站点—————————————————————Listen 80
NameVirtualHost 192.168.1.15 #接收请求的IP地址
<VirtualHost 192.168.1.15> #绑定的ip
ServerAdmin test@test.com #管理员邮箱DocumentRoot "D:/Inetpub/www/maidou/" #网站目录ServerName www.test.com #主机名(域名)
DirectoryIndex index.php #主目录默认页
ServerAlias test.other.com admin.other.com #做出响应的域名
ErrorLog logs/error_log.log #错误日志CustomLog logs/custom.log common #用户日志<Directory "D:/Inetpub/www/maidou/">Options Indexes FollowSymLinksAllowOverride All #AllowOverride指明Apache服务器是否加载.htacessOrder allow,denyAllow from all</Directory>
</VirtualHost>
# 多台可以再添加<VirtualHost 192.168.1.15>DocumentRoot "D:/Inetpub/www/other/"ServerName www.other.com
<Directory "D:/Inetpub/www/other/">Options Indexes FollowSymLinksAllowOverride AllOrder allow,denyAllow from all</Directory></VirtualHost>
根据自己的需要设置即可,除了DocumentRoot、ServerName是必须的外,其他几个设置都可以不要。

热点排行