From 954eccc781f95fb7aebd8be49737b19f212135c5 Mon Sep 17 00:00:00 2001 From: wenyongda Date: Fri, 17 Apr 2026 14:17:45 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0Nginx=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=92=8C=E9=85=8D=E7=BD=AE=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加Nginx的源码编译安装和AlmaLinux dnf安装方法 包含启动服务、防火墙配置以及目录结构说明 --- source/_posts/Linux软件安装.md | 48 +++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/source/_posts/Linux软件安装.md b/source/_posts/Linux软件安装.md index 1c6f144..fc36546 100644 --- a/source/_posts/Linux软件安装.md +++ b/source/_posts/Linux软件安装.md @@ -1345,4 +1345,50 @@ read only = yes [mysql_bakup] path = /root/mysql_bakup read only = yes -``` \ No newline at end of file +``` + +--- + +## Nginx 安装 + +### 源码编译安装 + +```shell +tar -zxvf nginx-1.21.4.tar.gz +cd nginx-1.21.4/ +./configure +make +make install +``` + +### AlmaLinux dnf 安装 + +```shell +# 确保软件是最新的 +sudo dnf clean all +sudo dnf update +sudo dnf groupinstall "Development Tools" + +# 安装 +sudo dnf install nginx + +# 启动并设置开机自启 +sudo systemctl restart nginx +sudo systemctl status nginx +sudo systemctl enable nginx + +# 防火墙放行 HTTP 和 HTTPS +sudo firewall-cmd --permanent --add-service=http +sudo firewall-cmd --permanent --add-service=https +sudo firewall-cmd --reload +``` + +### 目录结构 + +| 目录/文件 | 说明 | +|----------|------| +| `/etc/nginx` | 包含所有 Nginx 配置文件的主目录 | +| `/etc/nginx/nginx.conf` | 主要的 Nginx 配置文件 | +| `/etc/nginx/sites-available` | 定义各个网站的目录 | +| `/etc/nginx/sites-enabled` | Nginx 积极服务的网站列表 | +| `/var/log/nginx` | Nginx 日志目录 | \ No newline at end of file