LHEL6 配置apache基于域名的虚拟主机

    apache有两种虚拟主机,一种是基于ip的,一直是基于域名的。

    基于域名的虚拟主机允许多个域名共用一个ip地址。

    今天在配置虚拟主机的时候遇见如下问题,http.conf配置的都正确,内容如下:

  

   将NameVirtualHost *:80 的注释去掉。
 <VirtualHost *:80>
    ServerAdmin root@localhost
    DocumentRoot /www/virtual
    ServerName station.domain40.example.com
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin root@localhost
    DocumentRoot /www/virtual1
    ServerName www.domain40.example.com
</VirtualHost>
 
感觉配置的没有问题,后来好长时间发现是selinux的关系,查看apache的selinux配置文件
man httpd_selinux
 
设置 /www/virtual的selinux上下文
执行命令:
chcon -R -t http_sys_content_t /www/virtual/index.html
查看/www/virtual/index.html的上下文
ls -Z /www/virtual/index.html
即可。。
 
 
 
posted @ 2013-04-17 00:08  天添  阅读(252)  评论(0编辑  收藏  举报