RHCE 作业三

本文指导如何为OpenLab建立基于域名www.openlab.com的web网站,创建学生信息、教学资料和缴费网站的子界面。同时,设置了访问控制,限制学生信息网站仅song和tian可访问,并通过HTTPS实现缴费网站的数据加密访问,安装mod_ssl插件,生成并配置SSL证书。
摘要由CSDN通过智能技术生成

综合练习: 请给openlab搭建web网站

网站需求:

1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!

创建目录,在客户端中写入映射关系;将welcome to openlab ! 写入目录中;最后重启服务;

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

mkdir:已创建目录 '/www'

mkdir:已创建目录 '/www/openlab'

[root@localhost ~]#vim /etc/hosts

127.0.0.1   localhost losalhost.localdomain localhost4 localhost4.localdomain

::1              localhost losalhost.localdomain localhost6 localhost6.localdomain

192.168.67.128 www.openlab.com

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

[root@localhost ~]#systemctl restart httpd

​

​

​

 2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于[www.openlab.com/student ]网站访问学生信息,[www.openlab.com/data]网站访问教学资料,[www.openlab.com/money] 网站访问缴费网站

​
[root@localhost ~]# mkdir /www/openlab/student

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

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

[root@localhost ~]# echo student > /www/openlab/student/index.html

[root@localhost ~]# echo data > /www/openlab/data/index,html

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

[root@localhost ~]# cat /www/openlab/student/index.html

创建两个用户tian和song

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

修改用户配置文件
 

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

检测:

 3.要求
(1) 学生信息网站只有song和tian两人可以访问,其他用户不能访问。
(2) 访问缴费网站实现数据加密基于https访问。

先安装mod_ssl插件

[root@localhost ~]# yum install mod_ssl

然后在/etc/pki/tls/private 目录下生成私钥文件

[root@localhost ~]# cd /etc/pki/tls/private/
[root@localhost private]# ll
总用量 0
[root@localhost private]# openssl genrsa -aes128 2048 > money.key
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
在/etc/pki/tls/certs目录下新建证书
[root@localhost private]# cd /etc/pki/tls/certs/
[root@localhost certs]# openssl req -utf8 -new -key /etc/pki/tls/private/money.key -x509 -days 365 -out money.crt
Enter pass phrase for /etc/pki/tls/private/money.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) []:shanxi
Locality Name (eg, city) [Default City]:xi'an
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:RHCE
Common Name (eg, your name or your server's hostname) []:localhost
Email Address []:money@qq.com
输入证书信息时,必须一次性写对,不能退格删除

主配置文件的编辑

/etc/httpd/conf.d/ssl.conf在结尾添加以下内容
 
<VirtualHost 192.168.38.128:443>
        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/money.crt
        SSLCertificateKeyFile /etc/pki/tls/private/money.key
        ServerName www.openlab.com
        DocumentRoot /www/openlab/money
</VirtualHost>
<Directory /www/openlab/money>
        AllowOverride none
        Require all granted
</Directory>

最后重启http服务

[root@localhost conf.d]# systemctl restart httpd

点击高级: 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值