标签:conf radmin links 管理员 host 禁用 服务器管理 使用 ted
##############################构建Web虚拟主###################################################################基于IP地址的虚拟主机#########################<br/>####开启虚拟机主机功能模块####<br/>
vi /usr/local/httpd/conf/httpd.conf
#Listen localhost:80 #必须禁用
#Virtual hosts
Include conf/extra/httpd-vhosts.conf #这行前面的#去掉 vhosts模块生效
`
cd /usr/local/httpd/conf/extra/
vi httpd-vhosts.conf
<br/>######为了直接显示源代码,在后面添加ab、aa为主页文件##<br/>vi /usr/local/httpd/httpd.conf <br/>**<IfModule dir_module>**<br/>DirectoryIndex index.html ab.html aa.html<br/>**</IfModule>**<br/>
####默认的实列#去掉####
#<VirtualHost :80>
#ServerAdmin webmaster@dummy-host.example.com
#DocumentRoot "/usr/local/httpd/docs/dummy-host.example.com"
#ServerName dummy-host.example.com
#ServerAlias www.dummy-host.example.com
#ErrorLog "logs/dummy-host.example.com-error_log"
#CustomLog "logs/dummy-host.example.com-access_log" common
#</VirtualHost>
`
#<VirtualHost :80>
#ServerAdmin webmaster@dummy-host2.example.com
#DocumentRoot "/usr/local/httpd/docs/dummy-host2.example.com"
#ServerName dummy-host2.example.com
#ErrorLog "logs/dummy-host2.example.com-error_log"
#CustomLog "logs/dummy-host2.example.com-access_log" common
#</VirtualHost>
`
<VirtualHost 192.168.10.11:80>
ServerAdmin admin@aa.com ####设置http服务器管理员的E-mail地址,可以通过E-mail地址联系WEB站点的管理员
DocumentRoot /opt/aa/ ####设置网站跟目录,即网页在系统中存放的路径
ServerName www.aa.com ####设置网站的完整主机名,即(主机名+域名)
ErrorLog logs/aa.com-error_log ####错误日志存放路径
CustomLog logs/aa.com-access_log common ####访问日志文件路劲
</VirtualHost>
Listen 192.168.20.11:80
<VirtualHost 192.168.20.11:80>
ServerAdmin admin@ab.com
DocumentRoot /opt/ab/
ServerName www.ab.com
ErrorLog logs/ab.com-error_log
CustomLog logs/ab.com-access_log common
</VirtualHost>
<br/>######验证#####<br/>service httpd restart<br/>登录客户端的浏览器测试!!!<br/>测试2个地址: <br/>1、192.168.10.11<br/>2、192.168.20.11<br/>
<VirtualHost 192.168.10.11:80>
ServerAdmin admin@aa.com
DocumentRoot /opt/aa/
ServerName www.aa.com
ErrorLog logs/aa.com-error_log
CustomLog logs/aa.com-access_log common
</VirtualHost>
Listen 192.168.10.11:8080
<VirtualHost 192.168.10.11:8080>
ServerAdmin admin@ab.com
DocumentRoot /opt/ab/
ServerName www.ab.com
ErrorLog logs/ab.com-error_log
CustomLog logs/ab.com-access_log common
</VirtualHost>
<Directory "/opt/ab">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
`
######验证#####
service httpd restart
登录客户端的浏览器测试!!!
测试2个地址:
1、192.168.10.11:80
2、192.168.10.11:8080
###########################基于域名的虚拟主机###################
Listen 192.168.10.74:80
`
*<VirtualHost :80>
ServerAdmin admin@aa.com
DocumentRoot /opt/aa/
ServerName www.aa.com
ErrorLog logs/aa.com-error_log
CustomLog logs/aa.com-access_log common
</VirtualHost>**
*<VirtualHost :80>
ServerAdmin admin@ab.com
DocumentRoot /opt/ab/
ServerName www.ab.com
ErrorLog logs/ab.com-error_log
CustomLog logs/ab.com-access_log common
</VirtualHost>**
<Directory "/opt/ab">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
######验证#####
service httpd restart
登录客户端的浏览器测试!!
####
客户端需要在hosts文件添加域名解析:
192.168.10.11 www.aa.com
192.168.10.11 www.ab.com
####
测试2个地址:
1、www.aa.com
2、www.ab.com
标签:conf radmin links 管理员 host 禁用 服务器管理 使用 ted
原文地址:http://blog.51cto.com/13348945/2157976