RHCE第四天案例

RHCE第四天的两个案例:

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf 

#以下的是openlab网站
<VirtualHost 192.168.72.105:80>
        DocumentRoot /www/openlab
        alias /student /openlab/student/
        alias /data /openlab/data/
        alias /money /openlab/money/
        ServerName www.openlab.com				#这里要去改Windows中的hosts文件
</VirtualHost>

<Directory /openlab>
        AllowOverride none
        Require all granted
</Directory>

[root@localhost ~]# systemctl restart httpd

										#创建相应文件夹
										
[root@localhost ~]# mkdir /www/openlab
[root@localhost ~]# echo "welcome to openlab" > /www/openlab/index.html
[root@localhost ~]# cd /
[root@localhost /]# mkdir openlab
[root@localhost /]# cd openlab/
[root@localhost openlab]# mkdir student data money
[root@localhost openlab]# echo this is data > data/index.html
[root@localhost openlab]# echo this is money > money/index.html
[root@localhost openlab]# echo this is student > student/index.html


#要求:学生信息只有song和tian两人可以访问:
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf 

<Directory /openlab/student>
        Authtype Basic
        AuthName "openlab"
        AuthUserFile /etc/httpd/users
        Require user song tian
</Directory>

#添加song和tian用户
[root@localhost ~]# htpasswd /etc/httpd/users song
New password: 
Re-type new password: 
Adding password for user song
[root@localhost ~]# htpasswd /etc/httpd/users tian
New password: 
Re-type new password: 
Adding password for user tian


#要求:访问缴费网站实现数据加密基于https访问
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf 

<VirtualHost 192.168.72.105:443>
        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/openlab.crt
        SSLCertificateKeyFile /etc/pki/tls/private/openlab.key
        DocumentRoot /www/openlab
        alias /money /openlab/money/
        ServerName www.openlab.com
</VirtualHost>

#最后restart httpd
[root@localhost ~]# systemctl restart httpd

总结一下vhosts.conf:

在这里插入图片描述

在这里插入图片描述

[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf 

#以下的是不同部门间的文件传输

Listen 10000

<VirtualHost 192.168.72.104:10000>
        DocumentRoot /www/FileSharing
        ServerName 192.168.72.104
        alias /tec /FileSharing/Technology
        alias /dev /FileSharing/Development
</VirtualHost>

<Directory /FileSharing/Technology>
        Options +Indexes
        Authtype Basic
        AuthName "share"
        AuthUserFile /etc/httpd/users
        Require user tecuser
</Directory>

<Directory /FileSharing/Development>
        Options +Indexes
        Authtype Basic
        AuthName "share"
        AuthUserFile /etc/httpd/users
        Require user devuser
</Directory>
														#添加用户
[root@localhost ~]# htpasswd /etc/httpd/users tecuser
New password: 
Re-type new password: 
Adding password for user tecuser
[root@localhost ~]# htpasswd /etc/httpd/users devuser
New password: 
Re-type new password: 
Adding password for user devuser

[root@localhost ~]# cd /www
[root@localhost www]# mkdir FileSharing
[root@localhost www]# echo "this is FileSharing" > FileSharing/index.html
[root@localhost www]# cd /
[root@localhost /]# mkdir -p FileSharing/Technology/{file1,file2,file3,file4}
[root@localhost /]# mkdir -p FileSharing/Development/{file1,file2,file3,file4}
[root@localhost /]# cd 
[root@localhost ~]# systemctl restart httpd

打开浏览器看效果:

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值