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 LHEL6 配置apache基于域名的虚拟主机www.domain40.example.com
</VirtualHost>
 
感觉配置的没有问题,后来好长时间发现是selinux的关系,查看apache的selinux配置文件
man httpd_selinux
LHEL6 配置apache基于域名的虚拟主机
 
设置 /www/virtual的selinux上下文
执行命令:
chcon -R -t http_sys_content_t /www/virtual/index.html
查看/www/virtual/index.html的上下文
ls -Z /www/virtual/index.html
LHEL6 配置apache基于域名的虚拟主机
即可。。
 
 
 

相关文章:

  • 2021-08-08
  • 2022-12-23
  • 2021-12-13
  • 2021-11-13
  • 2022-12-23
  • 2021-12-17
  • 2022-02-02
猜你喜欢
  • 2022-01-01
  • 2022-12-23
  • 2022-01-09
  • 2021-07-29
  • 2021-09-12
  • 2022-12-23
  • 2021-05-30
相关资源
相似解决方案