RHCE: 关于web服务器学习的一些作业

文章介绍了如何在Linux服务器上使用Nginx配置网站,包括安装、防火墙与SELinux管理、创建子域名、设置权限(仅限指定用户访问)、添加HTTPS支持等内容。详细步骤涉及Windows客户端的Host文件修改和SSL证书生成。
摘要由CSDN通过智能技术生成

服务端: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-tools
yum 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.测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序二刺猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值