RHCE 练习3

e051f6cae20e400ab216ec52a52ad18e.png

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

下载hpptd

dnf install -y httpd

进入 vim /etc/httpd/conf.d/vhosts.conf 更改网址

<Directory "/www/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

<VirtualHost 192.168.225.128:80>
DocumentRoot "/www/openlab"
ServerName www.openlab.com
ErrorLog "/www/openlab/logs/error_log"
CustomLog "/www/openlab/logs/access_log" combined
</VirtualHost>

进入 vim /etc/hosts 添加配置

192.168.225.128 www.openlab.com

cd到html

cd /var/www/html

输入网站内容

echo welcome to openlab!!! > index.html

在 C:\Windows\System32\drivers\etc\hosts中保存

192.168.225.128 www.openlab.com

重启网络服务

systemctl start httpd

 关闭防火墙

firewall-cmd --permanent --add-service=http

立即生效

firewall-cmd --reload

357a597a9cb94f2a9ff26856cd393a30.png

用Edge浏览器登录本地www.openlab.com 

a8dcea5037964ad3907749853ff7e39c.png

 

2、给该公司创建的三个子页面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/stdent网站访问学生信息,www.openlab.com/data网站访问教学资料,www.openlab.com/money网站访问缴费网站。要求:学生信息网站只有tian和song两人可以访问,其他用户不能访问;访问缴费网站实现数据加密基于https访问。
 

创建目录并写入内容

mkdir /www/openlab/student
mkdir /www/openlab/data
mkdir /www/openlab/money
echo student > /www/openlab/student/index.html
echo data > /www/openlab/data/index.html
echo money > /www/openlab/money/index.html
cat /www/openlab/student/index.html 

创建用户

htpasswd -c /etc/httpd/user song
New password: 
Re-type new password: 
Adding password for user song

htpasswd  /etc/httpd/user tian
New password: 
Re-type new password: 
Adding password for user tian

在 vim /etc/httpd/conf.d/userdir.conf 修改

0c79a4955db540fcb96fc2738628af19.png

 

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

下载mod_ssl

yum install mod_ssl
cd /etc/pki/tls/private/
openssl genrsa -aes128 2048 > money.key
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
在/etc/pki/tls/certs目录下新建证书
cd /etc/pki/tls/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

在 vim /etc/httpd/conf.d/ssl.conf 更改


 <VirtualHost 192.168.225.128:81>
        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>

重启httpd

systemctl restart httpd

关闭防火墙

systemctl stop firewalld.service

你的连接不是专用链接,高级,继续访问192.168.225.128

34ee29ca801a4eb9a675185c6677342a.png

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值