一 、编辑 hosts 本地解析
[root@pcchaoren ~]# vim /etc/hosts
添加 ip 与 域名 对应
192.168.222.10 www.linuxprobe.com bbs.linuxprobe.com tech.linuxprobe.com
二、编译apache 配置文件
[root@pcchaoren ~]# vim /etc/httpd/conf/httpd.conf
113行 增加
<VirtualHost 192.168.222.10>
DocumentRoot "/home/wwwroot/www"
ServerName "www.linuxprobe.com"
<Directory "/home/wwwroot/www">
AllowOverride None
Require all granted
</directory>
</VirtualHost>
<virtualhost 192.168.222.10>
documentroot "/home/wwwroot/bbs"
servername "bbs.linuxprobe.com"
<directory "/home/wwwroot/bbs">
allowoverride none
require all granted
</directory>
</virtualhost><virtualhost 192.168.222.10>
documentroot "/home/wwwroot/tech"
servername "tech.linuxprobe.com"
<directory "/home/wwwroot/tech">
allowoverride none
require all granted
</directory>
</virtualhost>
经过测试 这里添加的配置参数不区分大小写
[root@pcchaoren ~]# systemctl restart httpd 重启服务
[root@pcchaoren ~]# systemctl enbale httpd 添加到开时启动
三 添加对应目录和文件
[root@pcchaoren ~]# mkdir -p /home/wwwroot/www
[root@pcchaoren ~]# echo "www.linuxprobe.com" > /home/wwwroot/www/index.html[root@pcchaoren ~]# mkdir -p /home/wwwroot/bbs
[root@pcchaoren ~]# echo "bbs.linuxprobe.com" > /home/wwwroot/bbs/index.html[root@pcchaoren ~]# mkdir -p /home/wwwroot/tech
[root@pcchaoren ~]# echo "tech.linuxprobe.com" > /home/wwwroot/tech/index.html
四 关闭 selinux 测试
setenfore 0
然后输入域名 ,打开 ,正常显示
五 开始selinux
setenfore 1
开始 修改 selinux 上下文
[root@pcchaoren ~]# semanage fcontext -at httpd_sys_content_t /home/wwwroot
[root@pcchaoren ~]# semanage fcontext -at httpd_sys_content_t /home/wwwroot/www
[root@pcchaoren ~]# semanage fcontext -at httpd_sys_content_t /home/wwwroot/www/*
[root@pcchaoren ~]# semanage fcontext -at httpd_sys_content_t /home/wwwroot/bbs
[root@pcchaoren ~]# semanage fcontext -at httpd_sys_content_t /home/wwwroot/bbs/*
[root@pcchaoren ~]# semanage fcontext -at httpd_sys_content_t /home/wwwroot/tech
[root@pcchaoren ~]# semanage fcontext -at httpd_sys_content_t /home/wwwroot/tech/*
[root@pcchaoren ~]# restorecon -Rv /home/wwwroot
restorecon reset /home/wwwroot context unconfined_u:object_r:home_root_t:s0->unconfined_u:object_r:httpd_sys_content_t:s0
restorecon reset /home/wwwroot/www context unconfined_u:object_r:home_root_t:s0-
>unconfined_u:object_r:httpd_sys_content_t:s0
restorecon reset /home/wwwroot/www/index.html context unconfined_u:object_r:home_root_t:s0-
>unconfined_u:object_r:httpd_sys_content_t:s0
restorecon reset /home/wwwroot/bbs context unconfined_u:object_r:home_root_t:s0-
>unconfined_u:object_r:httpd_sys_content_t:s0
restorecon reset /home/wwwroot/bbs/index.html context unconfined_u:object_r:home_root_t:s0-
>unconfined_u:object_r:httpd_sys_content_t:s0
restorecon reset /home/wwwroot/tech context unconfined_u:object_r:home_root_t:s0-
>unconfined_u:object_r:httpd_sys_content_t:s0
restorecon reset /home/wwwroot/tech/index.html context unconfined_u:object_r:home_root_t:s0-
>unconfined_u:object_r:httpd_sys_content_t:s0
完