RHCE练习

该文详细描述了如何基于域名www.openlab.com搭建和配置服务器,包括安装httpd,设置hosts,创建目录和网页内容,修改配置文件以创建学生、教学资料和缴费三个子界面。此外,还设置了访问权限,仅允许song和tian访问学生信息页面,并实现了缴费网站的HTTPS加密访问,确保数据安全。
摘要由CSDN通过智能技术生成

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

 安装服务器软件

dnf install -y httpd

 更改配置文件

vim /etc/hosts

 

 

192.168.17.130  www.openlab.com                                   

 创建目录,并在创建文件下写入welcome to openlabll !!!

mkdir -p /www/openlab
ls /www

echo "welcome to openlab!!!" > /www/openlab/index.html
cat /www/openlab/index.html

 修改网页的配置文件

vim /etc/httpd/conf.d/openlab.conf

<VirtualHost 192.168.17.130:80>
DocumentRoot /www/openlab
ServerName www.openlab.com
ErrorLog "/var/log/httpd/130-error_log"
CustomLog "/var/log/httpd/130-access_log" common
</VirtualHost>
<directory /www/openlab>    
AllowOverride None
Require all granted
</directory>
~                 

 

 关闭防火墙以及setenforce源

systemctl stop firewalld
setenforce 0

重启hppd服务 

systemctl restart httpd

 

 访问验证

curl www.openlab.com

 

给该公司创建三个子界面分别显示学生信息,

教学资料和缴费网站,基于[www.openlab.com/student](http://www.openlab.com/student)

网站访问学生信息,[www.openlab.com/data](http://www.openlab.com/data)

网站访问教学资料[www.openlab.com/money网站访问缴费网站](http://www.openlab.com/money网站访问缴费网站)。 

创建子界面目录 

mkdir /www/openlab/{student,data,money}
echo "学生信息" > /www/openlab/student/index.html
echo "教学资料" > /www/openlab/data/index.html
echo "缴费网站" > /www/openlab/money/index.html

修改配置文件

vim /etc/httpd/conf.d/openlab.conf

<VirtualHost 192.168.26.130:80>
     DocumentRoot /www/openlab/student
     ServerName www.openlab.com/student
     ErrorLog "/var/log/httpd/student-error_log"
     CustomLog "/var/log/httpd/student-access_log" common
 </VirtualHost>
 <VirtualHost 192.168.26.130:80>
     DocumentRoot /www/openlab/data
     ServerName www.openlab.com/data
     ErrorLog "/var/log/httpd/data-error_log"
     CustomLog "/var/log/httpd/data-access_log" common
 </VirtualHost>
 <VirtualHost 192.168.26.130:80>
     DocumentRoot /www/openlab/money    
     ServerName www.openlab.com/money
     ErrorLog "/var/log/httpd/money-error_log"
     CustomLog "/var/log/httpd/money-access_log" common
</VirtualHost> 

 

重启hppd服务 

systemctl restart httpd

测试能否访问成功

curl www.openlab.com/student/
curl www.openlab.com/data/
curl www.openlab.com/money/

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

首先我们就创建song和tian这两个用户

 

htpasswd -c /etc/httpd/mymima song
htpasswd  /etc/httpd/mymima tian

编辑配置文件修改他们的访问权限 

vim /etc/httpd/conf.d/openlab.conf

 <directory /www/openlab/student>
     AllowOverride None
     authtype basic
     authname "please login"
     authuserfile /etc/httpd/mymima
     require user song tian
</directory> 

重启

systemctl restart httpd

 

 客户端访问

curl www.openlab.com/student/ -u tian
curl www.openlab.com/student/ -u song

  

 安装mod_ssl

dnf install mod_ssl -y

 编辑配置文件修改他们的访问权限

vim /etc/httpd/conf.d/openlab.conf

 <virtualhost 192.168.17.130:443>

        servername www.openlab.com

        documentroot /www/openlab/money

        sslengine on

        SSLCertificateFile /etc/pki/tls/certs/openlab.crt

        SSLCertificateKeyFile /etc/pki/tls/private/openlab.key

</virtualhost>

<directory /www/openlab/money>

allowoverride none
         require  all granted
</directory>

 

 重启

systemctl restart httpd

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

孤冢清风666

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值