CentOS6 Apache配置详解(中)
#######################################################################
虚拟主机
Apache支持基于ip的虚拟主机和基于域名的虚拟主机
#######################################################################
1.基于IP,分两种情况,
ip相同,端口不同
vi /etc/httpd/cond.d/virtual.conf
Options
Indexes MultiViews FollowSymLinks
AllowOverride None
Order
allow,deny
Allow from
all
Options
Indexes MultiViews FollowSymLinks
AllowOverride None
Order
allow,deny
Allow from
all
Listen 8000
Listen 8001
ServerAdmin liujun_ok@hotmail.com
DocumentRoot
/var/www/test2
DirectoryIndex
index.html
ErrorLog
/var/log/httpd/test2.jlive.com_err
CustomLog
/var/log/httpd/test2.jlive.com_log combined
ServerAdmin liujun_ok@hotmail.com
DocumentRoot
/var/www/test1
DirectoryIndex
index.html
ErrorLog
/var/log/httpd/test1.jlive.com_err
CustomLog
/var/log/httpd/test1.jlive.com_log combined
#######################################################################
端口相同,ip不同
Options
Indexes MultiViews FollowSymLinks
AllowOverride None
Order
allow,deny
Allow from
all
Options
Indexes MultiViews FollowSymLinks
AllowOverride None
Order
allow,deny
Allow from
all
ServerAdmin liujun_ok@hotmail.com
DocumentRoot
/var/www/test2
ServerName
192.168.100.2:80
DirectoryIndex
index.html
ErrorLog
/var/log/httpd/test2.jlive.com_err
CustomLog
/var/log/httpd/test2.jlive.com_log combined
ServerAdmin liujun_ok@hotmail.com
DocumentRoot
/var/www/test1
ServerName
192.168.100.1:80
DirectoryIndex
index.html
ErrorLog
/var/log/httpd/test1.jlive.com_err
CustomLog
/var/log/httpd/test1.jlive.com_log combined
#######################################################################
基于域名
1.必须用NameVirtualHost指定哪个ip地址负责响应对虚拟主机的请求
NameVirtualHost
*:80
本机任何接口的80端口所指定的虚拟主机
NameVirtualHost
*:8000
本机任何接口的8000端口所指定的虚拟主机
NameVirtualHost 192.168.100.2:80
192.168.100.2的80端口负责响应
Listen 8000
Listen 8001
规范目录权限
Options
Indexes MultiViews FollowSymLinks
AllowOverride None
Order
allow,deny
Allow from
all
Options
Indexes MultiViews FollowSymLinks
AllowOverride None
Order
allow,deny
Allow from
all
设置虚拟主机
ServerAdmin liujun_ok@hotmail.com
DocumentRoot
/var/www/html
ServerName
www.jlive.com
ServerAdmin liujun_ok@hotmail.com
DocumentRoot
/var/www/test1
ServerName
test1.jlive.com:8000
DirectoryIndex
index.html
ErrorLog
/var/log/httpd/test1.jlive.com_err