From 20488f14699d2b5a0ab155fe5eefd3eb513e73a2 Mon Sep 17 00:00:00 2001 From: Chunmei Xu Date: Tue, 6 Dec 2022 17:32:26 +0800 Subject: [PATCH] update nginx course Signed-off-by: Chunmei Xu --- anolis-courses/nginx/deploy/index.yaml | 2 +- anolis-courses/nginx/deploy/step2.md | 27 +++++++++++++++--------- anolis-courses/nginx/deploy/step3.md | 16 +++++++++----- anolis-courses/nginx/deploy/step4.md | 29 +++++++++++++++++++------- anolis-courses/nginx/deploy/step5.md | 4 +--- anolis-courses/nginx/deploy/step6.md | 15 ++++++++----- anolis-courses/nginx/deploy/step7.md | 25 +++++++++++----------- 7 files changed, 74 insertions(+), 44 deletions(-) diff --git a/anolis-courses/nginx/deploy/index.yaml b/anolis-courses/nginx/deploy/index.yaml index 59b03b3..a919e6d 100755 --- a/anolis-courses/nginx/deploy/index.yaml +++ b/anolis-courses/nginx/deploy/index.yaml @@ -3,7 +3,7 @@ desc: 部署nginx,并自定义HelloWorld image: Anolis OS 8.4 ANCK 64位 live_time: 30min machine: x86_64-2c4g -max_clients: 1 +max_clients: 5 details: steps: start: start.md diff --git a/anolis-courses/nginx/deploy/step2.md b/anolis-courses/nginx/deploy/step2.md index 9cc25c5..aa53869 100755 --- a/anolis-courses/nginx/deploy/step2.md +++ b/anolis-courses/nginx/deploy/step2.md @@ -1,10 +1,17 @@ -```bash -dnf install nginx -y -systemctl status nginx -systemctl start nginx -# 防火墙配置 -systemctl status firewalld -firewall-cmd --list-ports -firewall-cmd --zone=public --add-port=80/tcp --permanent -firewall-cmd --reload -``` \ No newline at end of file +1. 安装nginx: + +[[ dnf install nginx -y ]] + +2. 启动nginx服务 + +[[ systemctl start nginx ]] + +3. 配置防火墙 + +[[ systemctl status firewalld ]] + +如果防火墙服务未开启,则跳过如下步骤: + +[[ firewall-cmd --list-ports ]] +[[ firewall-cmd --zone=public --add-port=80/tcp --permanent ]] +[[ firewall-cmd --reload ]] \ No newline at end of file diff --git a/anolis-courses/nginx/deploy/step3.md b/anolis-courses/nginx/deploy/step3.md index 3d0dae1..dcbb3b0 100755 --- a/anolis-courses/nginx/deploy/step3.md +++ b/anolis-courses/nginx/deploy/step3.md @@ -1,6 +1,12 @@ -```bash -curl 127.0.0.1 +1. 本地访问 -# 网页访问 -http://xx.xx.xx.xx -``` \ No newline at end of file +[[ curl 127.0.0.1 ]] + +2. 网页访问 + +通过如下方式获取公网ip: + +[[ curl myip.ipip.net ]] + +获取到公网ip之后,通过浏览器输入ip访问: +http://xx.xx.xx.xx \ No newline at end of file diff --git a/anolis-courses/nginx/deploy/step4.md b/anolis-courses/nginx/deploy/step4.md index 52c2576..6fa68b2 100755 --- a/anolis-courses/nginx/deploy/step4.md +++ b/anolis-courses/nginx/deploy/step4.md @@ -1,8 +1,12 @@ -```bash -cd /usr/share/nginx/html -mkdir helloworld -cd helloworld -# 创建helloworld.html,内容如下: +1. 添加helloworld页面 + +[[ cd /usr/share/nginx/html ]] +[[ mkdir -p helloworld ]] +[[ cd helloworld ]] + +使用vim编辑hello.html,内容如下: + +``` @@ -11,13 +15,22 @@ cd helloworld

Hello World

+``` + +2. 修改nginx配置文件 -# 编辑/etc/nginx/nginx.conf文件,添加hello.html文件的location -# 在原有的内容: +编辑/etc/nginx/nginx.conf文件,添加hello.html文件的location +在原有的内容: + +``` error_page 404 /404.html; location = /404.html { } -# 上方添加如下内容: +``` + +上方添加如下内容: + +``` location /hello.html { root /usr/share/nginx/html/helloworld; } diff --git a/anolis-courses/nginx/deploy/step5.md b/anolis-courses/nginx/deploy/step5.md index 3d19d4b..d242032 100755 --- a/anolis-courses/nginx/deploy/step5.md +++ b/anolis-courses/nginx/deploy/step5.md @@ -1,3 +1 @@ -```bash -systemctl restart nginx -``` \ No newline at end of file +[[ systemctl restart nginx ]] diff --git a/anolis-courses/nginx/deploy/step6.md b/anolis-courses/nginx/deploy/step6.md index 456f1f9..12c29d3 100755 --- a/anolis-courses/nginx/deploy/step6.md +++ b/anolis-courses/nginx/deploy/step6.md @@ -1,6 +1,11 @@ -```bash -curl http://127.0.0.1:80/hello.html +1. 本地访问 -# 页面访问 -http://xx.xx.xx.xx:80/hello.html -``` \ No newline at end of file +[[ curl http://127.0.0.1:80/hello.html ]] + +2. 页面访问 + +通过如下方式获取公网ip: +[[ curl myip.ipip.net ]] + +获取到公网ip后,使用浏览器访问。 +http://xx.xx.xx.xx:80/hello.html \ No newline at end of file diff --git a/anolis-courses/nginx/deploy/step7.md b/anolis-courses/nginx/deploy/step7.md index 5a4a1a5..29fbd6f 100755 --- a/anolis-courses/nginx/deploy/step7.md +++ b/anolis-courses/nginx/deploy/step7.md @@ -1,12 +1,13 @@ -```bash -# 删除自定义界面 -rm -rf /usr/share/nginx/html/helloworld -# 停止nginx服务 -systemctl stop nginx -systemctl status nginx -# 卸载nginx -dnf -y remove nginx -# 清除防火墙规则 -firewall-cmd --zone=public --remove-port=80/tcp --permanent -firewall-cmd --reload -``` \ No newline at end of file +1. 删除自定义界面 +[[ rm -rf /usr/share/nginx/html/helloworld ]] + +2. 停止nginx服务 +[[ systemctl stop nginx ]] + +3. 卸载nginx +[[ dnf -y remove nginx ]] + +4. 清除防火墙规则 +防火墙服务没开启无需执行。 +[[ firewall-cmd --zone=public --remove-port=80/tcp --permanent ]] +[[ firewall-cmd --reload ]] -- Gitee