当前位置: 首页 > news >正文

RHCE-网站搭建

一.需求

网站需求:
1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student 网站访问学生信息,www.openlab.com/data网站访问教学资料
www.openlab.com/money网站访问缴费网站。
3.要求 (1)访问该网站http请求都通过https响应。
(2)学生信息网站只有song和tian两人可以访问,其他用户不能访问。

二.配置过程

(1)准备工作

  [root@localhost /]# systemctl disable  firewalld #关闭防火墙[root@localhost /]# systemctl disable selinux #关闭selinux[root@localhost /]# yum install nginx -y #安装nginx

(2) 配置

  1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!

[root@localhost /]# mkdir /usr/share/nginx/html/openlab
[root@localhost /]#echo "welcome to openlab" > /usr/share/nginx/html/openlab/index.html

2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student 网站访问学生信息,www.openlab.com/data网站访问教学资料
www.openlab.com/money网站访问缴费网站。

[root@localhost /]# mkdir /usr/share/nginx/html/openlab/{student,data,money} -p
[root@localhost /]# echo "学生信息页面" > /usr/share/nginx/html/openlab/student/index.html
[root@localhost /]# echo "教育资料" > /usr/share/nginx/html/openlab/data/index.html
[root@localhost /]# echo "缴费信息" > /usr/share/nginx/html/openlab/money/index.html

3.要求 (1)访问该网站http请求都通过https响应。
(2)学生信息网站只有song和tian两人可以访问,其他用户不能访问。

[root@localhost /]# vim /etc/nginx/conf.d/ssl.conf #进行ssl配置
server {listen 80 default_server; # 监听 HTTP 的 80 端口server_name www.openlab.com; # 定义服务器名称为 www.openlab.comreturn 301 https://www.openlab.com/; # 返回301重定向,将所有 HTTP 请求重定向到 HTTPS
}server {listen       443 ssl http2; # 监听 HTTPS 的 443 端口listen       [::]:443 ssl http2;server_name  www.openlab.com; # 再次定义服务器名称为 www.openlab.comroot         /usr/share/nginx/html/openlab; # 设置网站的根目录为 /usr/share/nginx/html/openlabssl_certificate "/etc/pki/nginx/openlab.crt"; # 指定 SSL 证书的路径ssl_certificate_key "/etc/pki/nginx/openlab.key"; # 指定与 SSL 证书对应的私钥路径ssl_session_cache shared:SSL:1m; # 设置 SSL 会话缓存,名称为 SSL,大小为 1MBssl_session_timeout  10m; # 设置 SSL 会话超时时间为 10 分钟ssl_ciphers PROFILE=SYSTEM;ssl_prefer_server_ciphers on;
}
[root@localhost /]# mkdir /etc/pki/nginx
[root@localhost /]# openssl  genrsa 2048 > /etc/pki/nginx/openlab.key
[root@localhost /]# openssl  req -utf8 -new -key /etc/pki/nginx/openlab.key  -x509  -days 365 -out /etc/pki/nginx/openlab.crt
[root@localhost /]# mkdir /etc/nginx/passwd
[root@localhost /]# htpasswd -bc /etc/nginx/passwd song 123 #创建用户song密码123
[root@localhost /]# htpasswd -b /etc/nginx/passwd tian 123 #创建用户tian密码123

三.结果验证

[root@localhost /]# curl -I http://www.openlab.com
HTTP/1.1 301 Moved Permanently
Server: nginx/1.20.1
Date: Sat, 08 Nov 2025 12:00:50 GMT
Content-Type: text/html
Content-Length: 169
Connection: keep-alive
Location: https://www.openlab.com/  #表明HTTP已重定向到HTTPS[root@localhost /]# curl -k https://www.openlab.com
welcome to openlab
[root@localhost /]# curl -k https://www.openlab.com/data/
教育资料
[root@localhost /]# curl -k https://www.openlab.com/money/
缴费信息
[root@localhost /]# curl -k https://www.openlab.com/student/
学生信息页面
[root@localhost /]# curl -k https://song:123@www.openlab.com/student/
学生信息页面
[root@localhost /]# curl -k https://tian:123@www.openlab.com/student/
学生信息页面 

http://www.dtcms.com/a/587586.html

相关文章:

  • 站内信息 wordpress简述网络营销的概念
  • 深圳建一个网站多少钱百度推广登录平台怎么收费
  • 4.3.6【2023统考真题】
  • .net网站开发优点网站备案网站类型
  • MySQL8.0的卸载与安装
  • 好公司的网站设计做网站有哪些注意事项
  • 网站建设方案流程做电商一年能赚多少钱
  • 微网站和小程序的区别网站建设云服务器与虚拟主机
  • 苏州化妆品网站建设大型网站许多网站
  • 深圳地铁网站开发网站是怎么做新手引导
  • 网站的动态体验图是什么软件做的网络推广运营的技巧
  • 免费推广网站入口202交河做网站
  • 网站建设企业咨询wordpress批量注册会员
  • 用jsp做的网站源代码做图网站被告
  • 临海市建设规划局网站wordpress文章上作者
  • 电子商务网站建设的背景广州品牌形象设计
  • 网上二手书网站开发中的问题和展望投资公司怎么赚钱
  • wordpress评论通知站长广告制作单位
  • 电子商务网站建设的策划书把网站做静态化是什么意思
  • 分析网站设计施工企业会计核算及常用会计分录
  • xxx网站建设策划书范文中山大学精品课程网站
  • 做 网站 要专线吗网站开发公司建网站
  • 大连网站建设哪家公司好仙桃做网站的公司
  • 合肥网站建设培训班wordpress怎么编辑网页
  • Ecology9明细表中添加操作按钮与弹窗功能技术分享
  • 银川网站建设多少钱wordpress wiki 模版
  • 南京定制网站哪个好做网站空间500m多少钱
  • 中山企业网站设计百度指数在哪里看
  • 为外国人做非法网站做普通网站需要服务器吗
  • 成都英文网站建设做外贸找生意上哪个网站