综合练习:请给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访问。
解答:
[root @localhost ~]# systemctl stop firewalld
[root @localhost ~]# setenforce 0
[root @localhost ~]# mount /dev/sr0 /mnt(media)
[root @localhost ~]# vim /etc/yum.repos.d/base.repo
进入vim以后写入命令:
[APPSTREAM]
name=appstreambaseurl=file:///media/AppStream/
gpgcheck=0
[BASEOS
name=baseos
baseurl=file:///media/BaseOS/
gpgcheck=0
最后':wq'保存退出。
安装yum源:
[root@localhost ~]# yum install bind-utils -y
检查安装完毕后,进入/etc/httpd/conf.d/中编写文件
<Virtualhost 192.168.171.128:80>
DocumentRoot /www/openlab
Servername www.openlab.com
</Virtualhost>
<Directory /www>
AllowOverride none
Require all granted
</Directory>
<Directory /www/openlab/student>
AuthType Basic
AuthName "Login...
AuthUserfile /etc/httpd/users
Require user song tian
</Directory>
<Virtualhost 192.168.171.128:443>
DocumentRoot /www/certs
Servername www.openlab.com
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/lhx.crt
SSLCertificateKeyFile /etc/pki/tls/certs/lhx.key
</Virtualhost>
保存退出:wq
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost ~]# mkdir /www/openlab -p
[root@localhost ~]# ehco 'welcome to openlab.' > /www/openlab/index.html
[root@localhost ~]# cat /www/openlab/index.html
welcome to openlab.
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# vim /etc/hosts
[root@localhost ~]# curl http://www.openlab.com
welcome to openlab.
[root@localhost ~]# mkdir /www/openlab/date
[root@localhost ~]# ehco this is date > /www/openlab/date/index.html
[root@localhost ~]# curl http://www.openlab.com/date/
this is date
[root@localhost ~]# mkdir /www/openlab/student
[root@localhost ~]# ehco this is student > /www/openlab/student/index.htnl
[root@localhost ~]# vim /etc/hosts
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost ~]# httpasswd -c /etc/httpd/users song
[root@localhost ~]# httpasswd -c /etc/httpd/users tian
[root@localhost ~]# cat /etc/httpd/users
song:
tian:
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# curl http://www.openlab.com/student/ -u song:密码
this is student
[root@localhost ~]# mkdir /www/certs
[root@localhost ~]# mkdir /www/certs/money
[root@localhost ~]# ehco this is money > /www/certs/money/
[root@localhost ~]# mkdir /private
[root@localhost ~]# openlab genrsa 2048 > /private/lHX.key