网站需求:
- 基于域名[www.openlab.com](http ://www.openlab.com)可以访问网站内容为 welcome to openlab!!!
- 给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于[www.openlab.com/student](http://www.openlab.com/student) 网站访问学生信息,[www.openlab.com/data](http://www.openlab.com/data)网站访问教学资料,网站访问缴费网站(http://www.openlab.com/money网站访问缴费网站)。
- 要求
(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
(2)访问缴费网站实现数据加密基于https访问。
预处理
下载
[root@localhost ~]# dnf install nginx -y
[root@localhost ~]# dnf install httpd-tools -y
[root@localhost ~]# systemctl stop firewalld # 关闭防火墙
[root@localhost ~]# setenforce 0 # 临时关闭
[root@localhost ~]# systemctl start nginx # 启动nginx服务
[root@localhost ~]# systemctl start httpd # 启动httpd服务
新建目录
[root@localhost ~]# mkdir /www/openlab -pv
mkdir: 已创建目录 '/www'
mkdir: 已创建目录 '/www/openlab'
写入网页显示内容
[root@localhost ~]# echo "welcome to openlab!!!"> /www/openlab/index.html
创建 www.openlab.com
[root@localhost ~]# vim /etc/nginx/conf.d/www.conf

本机ip映射
主配置文件设置
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf

手动配置IP地址 与域名的映射关系,使用本地hosts配置文件实现
[root@localhost ~]# vim /etc/hosts

windows 端,打开C:\Windows\System32\drivers\etc\hosts,添加以下内容

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

创建子界面

创建一个student、data、money目录
[root@localhost ~]# mkdir /www/openlab/student
[root@localhost ~]# mkdir /www/openlab/data
[root@localhost ~]# mkdir /www/openlab/money
写入student、data、money网页内容
[root@localhost ~]# echo 'This is student' > /www/openlab/student/index.html
[root@localhost ~]# echo 'This is data' > /www/openlab/data/index.html
[root@localhost ~]# echo 'This is money' > /www/openlab/money/index.html
学生信息网站只有song和tian两人可以访问,其他用户不能访问
[root@localhost ~]# htpasswd -c /www/openlab/userfile song
New password:
Re-type new password:
Adding password for user song
[root@localhost ~]# htpasswd -c /www/openlab/userfile tian
New password:
Re-type new password:
Adding password for user tian
访问该网站http请求都通过https响应
[root@localhost ~]# vim /etc/nginx/conf.d/www.conf

[root@localhost ~]# openssl genrsa 2048 > /www/openlab/openlab.key
[root@localhost ~]# openssl req -utf8 -new -key /www/openlab/openlab.key -x509 -days 365 -out /www/openlab/openlab.crt
961



被折叠的 条评论
为什么被折叠?



