服务端:linux --> 192.168.17.131
客户端:windows ---> edge浏览器
三个题目依次关联
一.基于域名[www.openlab.com]可以访问网站内容为 welcome to openlab!!!
1 .nginx启动!!(yum install nginx可以下载)
1 .处理防火墙(firewall)和selinux
systemctl stop firewalld #关闭防火墙 setenforce 0 #将selinux变为Permissive状态
2.启动!!
systemctl start nginx
2.设置(创建server模块)
1.nginx总配置文件是/etc/nginx.conf
vim /etc/nginx.conf --> 可以找到子配置文件相关信息
2.设置子配置文件
创建子配置文件
touch /etc/nginx/conf.d/openlab.conf
添加server块
vim /etc/nginx/conf.d/openlab.conf
3.重启nginx
systemctl restart nginx
3.创建网站网页文件
创建网站根目录
mkdir /www/openlab -pv
往index.html里面写内容
echo welcome to openlab\!\!\! > /www/openlab/index.html
4.测试
因为没有dns,这里更改客户端的host文件: 这里用windows当客户端
C:\Windows\System32\drivers\etc\host
在末尾添加:
在浏览器输入网址:http:www.openlab.com
二:给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,
基于(http://www.openlab.com/student)网站访问学生信息,
(http://www.openlab.com/data)网站访问教学资料,
(http://www.openlab.com/money网站访问缴费网站
1.创建网站文件
mkdir /www/openlab/student mkdir /www/openlab/money mkdir /www/openlab/data
2.写内容
echo data > /www/openlab/data/index.html echo money > /www/openlab/money.html echo student > /www/openlab/student/index.html
3.测试(其中一个)
三:(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
(2)访问缴费网站实现数据加密基于https访问。
(1) :
1.更改server配置
2.下载httpd-toolsyum install httpd-tools
3.创建用户
htpasswd -c /etc/nginx/users tian New password: 123 Re-type new password:123
htpasswd -c /etc/nginx/users song New password: 123 Re-type new password:123
4.重启nginx
systemctl restart nginx
5.测试
(2):
1.添加https的server
还是在/etc/nginx/conf.d/openlab.conf 子配置文件中添加新的server模块
2.创建密钥和ca证书
#创建私钥 openssl genrsa -out /etc/pki/tls/private/openlab.key
# 创建ca证书 openssl req -utf8 -new -key /etc/pki/tls/private/openlab.key -x509 -days 365 -out /etc/pki/tls/certs/openlab.crt
创建ca证书时填几个信息,我这里随便填的
2.创建https网站的网页文件
mkdir /www/https/money echo money > /www/https/money/index.html
3.重启nginx
systemctl restart nginx
4.测试