huiselele 发表于 2018-11-24 12:07:24

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

  apache有两种虚拟主机,一种是基于ip的,一直是基于域名的。
  基于域名的虚拟主机允许多个域名共用一个ip地址。
  今天在配置虚拟主机的时候遇见如下问题,http.conf配置的都正确,内容如下:
  将NameVirtualHost *:80 的注释去掉。
   
    ServerAdmin root@localhost
    DocumentRoot /www/virtual
    ServerName station.domain40.example.com


    ServerAdmin root@localhost
    DocumentRoot /www/virtual1
    ServerName file:///C:UsersstevenAppDataLocalTemp%W@GJ$ACOF(TYDYECOKVDYB.pngwww.domain40.example.com

   
感觉配置的没有问题,后来好长时间发现是selinux的关系,查看apache的selinux配置文件
man httpd_selinux
http://images.cnitblog.com/blog/255323/201304/17000416-0a0d0503402b4e469b63775aba503d66.jpg
   
设置 /www/virtual的selinux上下文
执行命令:
chcon -R -t http_sys_content_t /www/virtual/index.html
查看/www/virtual/index.html的上下文
ls -Z /www/virtual/index.html
http://images.cnitblog.com/blog/255323/201304/17000729-72a2da059dca4befa4c9ec58b3cda7a5.png
即可。。
   
   
   



页: [1]
查看完整版本: LHEL6 配置apache基于域名的虚拟主机