rhce 第3天

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

网站需求:

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

2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于[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网站访问缴费网站)。

3.要求

(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。

(2)访问缴费网站实现数据加密基于https访问。

1、

安装http包,关闭firewalld和setenforce 0

 
[root@localhost yum.repos.d]# cat base.repo  
[base]
name=base
baseurl=file:///mnt/BaseOS
gpgcheck=0
 
[app]
name=appstream
baseurl=file:///mnt/AppStream
gpgcheck=0
 
[root@localhost yum.repos.d]# mount /dev/sr0 /mnt #挂载到本地光盘
[root@localhost conf.d]# systemctl stop firewalld.service 
[root@localhost conf.d]# yum install httpd -y
[root@localhost conf.d]# setenforce 0

更改配置文件

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost ~]# cat /etc/httpd/conf.d/vhosts.conf
<virtualhost 192.168.16.128:80>
  servername www.openlab.com
  documentroot /var/www/openlab
</virtualhost>
 
<directory /var/www/openlab>
  allowoverride none
  require all granted
</directory>
[root@localhost ~]# systemctl restart httpd  #重启httpd协议
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld #关闭防火墙
[root@localhost ~]# mkdir /var/www/openlab #创建对应目录
[root@localhost ~]# echo welcome to openlab > /var/www/openlab/index.html

测试1

[root@localhost conf.d]# vim /etc/hosts
[root@localhost conf.d]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.16.126 www.openlab.com
[root@localhost conf.d]# curl www.openlab.com
welcome to openlab

2、

[root@localhost ~]# mkdir /var/www/openlab/{student,data,money}
[root@localhost ~]# echo 学生信息网站 > /var/www/openlab/student/index.html
[root@localhost ~]# echo 教学资料网站 > /var/www/openlab/data/index.html
[root@localhost ~]# echo 缴费网站 > /var/www/openlab/money/index.html

测试2

[root@localhost conf.d]# curl www.openlab.com/data/
教学资料网站
[root@localhost conf.d]# curl www.openlab.com/student/
学生信息网站
[root@localhost conf.d]# curl www.openlab.com/money/
缴费网站

3、

创建song,tian用户

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost ~]# htpasswd -c /etc/httpd/mymima song
New password: 
Re-type new password: 
Adding password for user song
[root@localhost ~]# htpasswd -c /etc/httpd/mymima tian
New password: 
Re-type new password: 
Adding password for user tian
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost ~]# cat /etc/httpd/conf.d/vhosts.conf
<directory /var/www/openlab/student>
  allowoverride none
  authtype basic
  authname "please login"
  authuserfile /etc/httpd/mymima
  require user song tian
</directory>
 

测试3.1

[root@localhost conf.d]# curl www.openlab.com/student/ -u song
Enter host password for user 'song':
学生信息网站
[root@localhost conf.d]# curl www.openlab.com/student/ -u tian
Enter host password for user 'tian':
学生信息网站

3.2

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost ~]# cat /etc/httpd/conf.d/vhosts.conf
<virtualhost 192.168.16.126:443>
        servername www.openlab.com
        documentroot /var/www/openlab/money
        sslengine on
        SSLCertificateFile /etc/pki/tls/certs/localhost.crt
        SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
 
</virtualhost>
 
<directory /var/www/openlab/money>
    allowoverride none
    require  all granted
</directory>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值