rhce第三次作业

该文描述了如何为OpenLab搭建基于域名www.openlab.com的Web网站,包括创建三个子界面展示学生信息、教学资料和缴费网站。同时,设置了访问权限,仅song和tian可访问学生信息网站,并实现了缴费网站的数据加密通过HTTPS进行安全访问。

题目

综合练习:请给openlab搭建web网站
​ 网站需求:
​ 1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!
​ 2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student 网站访问学生信息,www.openlab.com/data网站访问教学资料
www.openlab.com/money网站访问缴费网站
​ 3.要求
​ (1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
​ (2)访问缴费网站实现数据加密基于https访问。

完成过程

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

<Virtualhost 192.168.101.200:80> #虚拟主机IP及端口
DocumentRoot /www/openlab #网页文件存放目录
ServerName www.openlab.com #服务器域名

<Directory /www>
AllowOverride none #不允许覆盖
Require all granted #允许访问

#利用本机的/etc/hosts文件做域名解析

[root@localhost ~]# vim /etc/hosts
192.168.101.200 www.openlab.com

#创建网页根目录

[root@localhost ~]# mkdir -p /www/openlab

#编辑网页内容

[root@localhost ~]# echo ‘welcome to openlab!!!’ > /www/openlab/index.html

#重启hppd服务

[root@localhost ~]# systemctl restart httpd

[root@localhost ~]# setenforce 0

#Client主机测试

[root@localhost ~]# curl www.openlab.com

welcome to openlab!!!
[root@localhost ~]# vim /etc/httpd/conf.d/vshots.conf

<VirtualHost 192.168.101.200:80>
DocumentRoot /www/openlab
别名 /data 实际路径 /www/openlab/data
Alias /data /www/openlab/data
ServerName www.openlab.com

#重启httpd服务

[root@localhost ~]# systemctl restart httpd

#创建/data网页根目录

[root@localhost ~]# mkdir /www/openlab/data

#编辑网页内容

[root@localhost ~]# echo ‘this is openlab data’ > /www/openlab/data/index.html

#Client主机测试

[root@localhost ~]# curl www.openlab.com/data/
this is openlab data
[root@localhost ~]# mount /dev/sr0 /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.

#下载mod_ssl 软件包

[root@localhost ~]# yum install mod_ssl -y

制作秘钥及证书
[root@localhost ~]# openssl req -newkey rsa:4096 -nodes -sha256 -keyout /etc/pki/tls/private/openlab.key -x509 -days 365 -out /etc/pki/tls/certs/openlab.crt
Generating a RSA private key
…++++
…++++
writing new private key to ‘/etc/pki/tls/private/openlab.key’

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.

Country Name (2 letter code) [XX]:86
State or Province Name (full name) []:shannxi
Locality Name (eg, city) [Default City]:xi’an
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:ce
Common Name (eg, your name or your server’s hostname) []:localhost
Email Address []:admin
[root@localhost ~]# vim /etc/httpd/conf.d/vshots.conf
<VirtualHost 192.168.101.200:443>
DocumentRoot /www/openlab
Alias /money /www/openlab/money
ServerName www.openlab.com
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/openlab.crt
SSLCertificateKeyFile /etc/pki/tls/private/openlab.key

#创建网页文件根目录

[root@localhost ~]# mkdir /www/openlab/money

#编辑子网页money内容

[root@localhost ~]# echo ‘this is openlab money’ > /www/openlab/money/index.html

#重启httpd服务

[root@localhost ~]# systemctl restart httpd

#Client主机测试

[root@localhost ~]# curl --insecure https://www.openlab.com/money/
this is openlab money
[root@server ~]# vim /etc/httpd/conf.d/vshots.conf
<VirtualHost 192.168.101.200:80>
DocumentRoot /www/openlab
Alias /student /www/openlab/student
ServerName www.openlab.com

<Directory /www/openlab/student>
AuthType Basic
AuthName “Please login:…”
AuthuserFile /etc/httpd/usrfile
Require user song tian

#创建用户 指定用户名及密码

[root@localhost ~]# htpasswd -c /etc/httpd/userfile song
New password:
Re-type new password:
Adding password for user song
[root@server ~]# htpasswd /etc/httpd/userfile tian
New password:
Re-type new password:
Adding password for user tian

#创建网页文件根目录

[root@server ~]# mkdir /www/openlab/student

#重启httpd服务

[root@server ~]# systemctl restart httpd

访问/student 子页面

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值