apache vps 基于域名 笔记

一 、编辑 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

 


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值