1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!
(1)关闭防护墙,关闭selinux
[root@nodel ~]# systemctl stop firewalld
[root@nodel ~]# setenforce 0
[root@nodel ~]# getenforce
Permissive
(2)安装对应服务软件 nginx
[root@nodel ~]# yum install nginx
(3)自定义nginx配置文件通过多域名访问网站
[root@nodel ~]# vim /etc/nginx/conf.d/Openlab.conf
[root@node1 ~]# vim /etc/hosts
(4)根据配置创建对应的主机数据文件,创建文件和目录,
并在文件中写入数据:
[root@nodel ~]# mkdir /www/name/Openlab -pv
[root@nodel ~]# echo welcome to openlab!!! > /www/name/Openlab/index.html
(5)重启服务加载配置
[root@nodel ~]# systemctl restart nginx
curl测试
[root@nodel ~]# curl 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)网站访问教学资料,网站访问缴费网站(http://www.openlab.com/money网站访问缴费网站)。
[root@nodel ~]# cd /www/name/openlab
[root@nodel openlab]# echo student > student.html
[root@nodel openlab]# echo data > data.html
[root@nodel openlab]# echo money > money.html
[root@nodel openlab]# curl http://www.openlab.com
hello openlabcurlcurlcurl www.openlab.com!
[root@nodel openlab]# curl http://www.openlab.com/student.html
student
[root@nodel openlab]# curl http://www.openlab.com/data.html
data
[root@nodel openlab]# curl http://www.openlab.com/money.html
money
3.要求 (1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
[root@nodel ~]# vim /etc/nginx/conf.d/openlab.conf
[root@nodel ~]# htpasswd -c /etc/nginx/users song
New password:
Re-type new password:
Adding password for user song
[root@nodel ~]# htpasswd -c /etc/nginx/users tian
New password:
Re-type new password:
Adding password for user tian
[root@nodel ~]# systemctl restart ngin
Failed to restart ngin.service: Unit ngin.service not found.
[root@nodel ~]# systemctl restart nginx
(2)访问缴费网站实现数据加密基于https访问。
[root@localhost ~]# vim /etc/nginx/conf.d/openlab.conf
[root@localhost ~]# vim /etc/nginx/conf.d/money.conf
[root@localhost ~]# mkdir /www/openlab/money
[root@localhost ~]# mv /www/openlab/money.html /www/openlab/money/
[root@localhost private]# openssl genrsa 2048 > money.key
[root@localhost certs]# openssl req -utf8 -new -key ../private/money.key -x509 -days 365 -out money.crt
[root@localhost certs]# systemctl restart nginx
测试: