RHCE第三次作业

网站需求
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访问。
一、准备阶段

服务器: IPV4:192.168.78.129/24
客户端: IPV4:192.168.78.130/24

服务器:
[root@localhost~]# systemctlstop firewalld   #关闭防火墙
[root@localhost]# setenforce 0               #关闭setenforce
[root@localhost]# yum install httpd mod_ssl -y  #安装httpd

二、配置
2.1配置服务器

[root@localhost]# mkdir -v /openlab/    #创建目录
[root@localhost]# echo "welcome to openlab!!!" > /openlab/index.html  
[root@localhost]# vim /etc/httpd/conf.d/openlab.conf
<Directory "/openlab/">
        Options Indexes FollowSymLinks                                       
        AllowOverride None  
        Require all granted                 
</Directory>
<VirtualHost 192.168.110.136:80>
    ServerAdmin admin@outlook.com
    DocumentRoot "/openlab/"
    ServerName www.openlab.com
</VirtualHost>

[root@localhost]# systemctl restart httpd         #重启httpd服务

2.2创建三个网站目录分别显示学生信息,教学资料和缴费网站
2.2.1 学生信息

[root@localhost~]# mkdir /openlab/student
[root@localhost~]# mkdir /openlab/data
[root@localhost~]# mkdir /openlab/money

[root@localhost~]# echo "学生信息" > /openlab/student/index.html
[root@localhost~]# echo "教育网站" > /openlab/data/index.html  
[root@localhost~]# echo "缴费网站" > /openlab/money/index.html

[root@localhost~]# htpasswd /etc/httpd/conf.d/httpd tian   #添加tian用户
New password:
Re-type new password:
Adding password for user tian

[root@localhost~]# htpasswd /etc/httpd/conf.d/httpd song  #添加song用户
New password:
Re-type new password:
Adding password for user song

[root@localhost~]#vim /etc/httpd/conf.d/openlab.conf
<VirtualHost 192.168.110.136:80>
    ServerAdmin admin@outlook.com
    DocumentRoot "/openlab/student"
    ServerName www.openlab.com
</VirtualHost>
<Directory "/openlab/student">
        Options Indexes FollowSymLinks
        AllowOverride None
        AuthType Basic
        AuthName "Restricted Files"
        AuthUserFile "/etc/httpd/conf.d/httpd "    #身份验证文件的路径
        Require user song tian                     #允许访问的用户列表
</Directory>

[root@localhost~]# systemctl restart httpd   #重启httpd服务

2.2.3.配置教学资料网站所有用户都可以访问

[root@localhost~]# vim /etc/httpd/conf.d/openlab.conf   #在openlab配置文件中追加内容
<Directory "/openlab/data/">
Options Indexes FollowSymLinks
  AllowOverride None
Require all granted
</Directory>
<VirtualHost 192.168.78.129:80>
    ServerAdmin admin@outlook.com
    DocumentRoot "/openlab/data/"
    ServerName www.openlab.com
</VirtualHost>

[root@localhost~]# systemctl restart httpd    #重启httpd服务

2.2.4配置缴费网站

[root@localhost~]# cd /etc/pki/tls/certs/  
[root@localhost crets]# openssl genrsa 2048 >> openlab.key    #生成私钥文件
[root@localhost crets]# openssl req -utf8 -new -key openlab.key -x509 -days 100 -out openlab.crt  #生成证书
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]:SN         
State or Province Name (full name) []:CN    
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) []:www.openlab.com  #域名
Email Address []:admi@outlook.com        #邮箱   

[root@localhost~]# vim /etc/httpd/conf.d/openlab.conf    #追加money的内容
<VirtualHost 192.168.78.129:443>
    DocumentRoot "/openlab/money/"
    ServerName www.openlab.com
    SSLEngine on
    SSLCertificateFile "/etc/pki/tls/certs/openlab.crt"
    SSLCertificateKeyFile "/etc/pki/tls/certs/openlab.key"
</VirtualHost>
<Directory "/openlab/money/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

[root@localhost~]# systemctl restart httpd    #重启httpd服务

客户端访问:

2.2.5客户端通过域名可以正常访问服务端内容

[root@client ~]# vim /etc/hosts                       
192.168.78.129       www.openlab.com
#将ip 192.168.78.129 映射到 www.openlab.com
2.2.6测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值