RHCE第三次作业

该文描述了如何配置Apache服务器以基于域名www.openlab.com创建不同子页面,展示学生信息、教学资料和缴费网站。通过设置VirtualHosts,创建相应目录和网页文件,并实现子页面访问。同时,对访问学生信息网站的用户进行了权限限制,仅允许song和tian两个用户访问,并通过htpasswd创建用户密码。另外,为了保护缴费网站的安全,使用HTTPS进行数据加密。
摘要由CSDN通过智能技术生成

1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!

[root@localhost ~]# rpm -ql httpd-core | grep  host
/usr/share/doc/httpd-core/httpd-vhosts.conf
[root@localhost ~]# rpm -ql httpd-core | grep etc
[root@localhost ~]# cd /etc/httpd/conf.d
[root@localhost conf.d]# cp /usr/share/doc/httpd-core/httpd-vhosts.conf ./zuoye.conf
2.创建文件
[root@localhost conf.d]# vim zuoye.conf 
<VirtualHost 192.168.226.60:80>
    DocumentRoot /www/zuoye/
    ServerName www.openlab.com
    ErrorLog "/var/log/httpd/openlab-error_log"
    CustomLog "/var/log/httpd/openlab-access_log" common
</VirtualHost>
<directory /www/zuoye>
    allowoverride none
    require all granted
</directory>
 
[root@localhost conf.d]# mkdir /www/zuoye -p
#创建目录
[root@localhost conf.d]# echo "welcome to openlab" > /www/zuoye/index.html
#创建网页文件
[root@localhost conf.d]# systemctl status firewalld
#查看防火墙是否关闭
[root@localhost conf.d]# setenforce 0
[root@localhost conf.d]# getenforce 
Permissive
[root@localhost conf.d]# systemctl restart httpd
#重启服务
测试:
[root@localhost conf.d]# curl 192.168.226.60
welcome to openlab
[root@localhost conf.d]# vim /etc/hosts
192.168.226.60 www.openlab.com
[root@localhost conf.d]# ping www.openlab.com
PING www.openlab.com (192.168.226.60) 56(84) bytes of data.
64 bytes from www.openlab.com (192.168.226.60): icmp_seq=1 ttl=64 time=0.032 ms
[root@localhost conf.d]# curl www.openlab.com
welcome to openlab
#注意:虚拟机之间不能配置相同的地址,实验可能会出现错误
如果是windows客户端则需要修改hosts文件,文件路径:(\Windows\System32\drivers\etc\)
如果是Linux客户端,也需要修改hosts文件,文件路径:(/etc/hosts)
3.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student 网站访问学生信息,www.openlab.com/data网站访问教学资料www.openlab.com/money网站访问缴费网站。

#给公司创建三个子页面
[root@localhost conf.d]# cd /www/zuoye
[root@localhost zuoye]# mkdir student data money
#在/www/zuoye下创建这三个目录
[root@localhost zuoye]# echo money > ./money/index.html
[root@localhost zuoye]# echo student > ./student/index.html
[root@localhost zuoye]# echo data > ./data/index.html
 
[root@localhost zuoye]# curl 192.168.106.129.6student
[root@localhost zuoye]# curl 192.168.106.129./student -L
student
#测试:
[root@localhost zuoye]# curl http://www.openlab.com/data/
data
[root@localhost zuoye]# curl http://www.openlab.com/student/
student
[root@localhost zuoye]# curl http://www.openlab.com/money/
money
4.要求 (1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。

(2)访问缴费网站实现数据加密基于https访问。

#创建用户 指定用户名及密码
 
[root@localhost ~]# htpasswd -c /etc/httpd/userfile song
New password: 
Re-type new password: 
Adding password for user song
[root@localhost ~]# htpasswd /etc/httpd/userfile tian
New password: 
Re-type new password: 
Adding password for user tian
 
#创建网页文件根目录
 
[root@localhost~]# mkdir /www/openlab/student
 
#重启httpd服务
 
[root@localhost ~]# systemctl restart httpd

结果:

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值