nginx1.24源码编译安装(Linux7.9环境)

1、下载nginx安装包tar.gz官方下载地址

bash 复制代码
cd /usr/local/
wget https://nginx.p2hp.com/download/nginx-1.24.0.tar.gz
tar -xvf nginx-1.24.0.tar.gz
cd nginx-1.24.0

安装所需依赖项

bash 复制代码
sudo yum install gcc gcc-c++ make -y
sudo yum install pcre pcre-devel
sudo yum install openssl-devel

配置编译选项 通过运行 ./configure 脚本来配置 Nginx。这里可以添加或改变默认配置选项。常见的选项包括:

--prefix:指定 Nginx 安装的目标目录。

--with-http_ssl_module:添加 HTTPS 支持。

--with-pcre:使用 PCRE 库来使用 http_rewrite_module 重写 URL。

示例配置命令:

bash 复制代码
./configure --prefix=/usr/local/nginx \
            --sbin-path=/usr/sbin/nginx \
            --modules-path=/usr/lib/nginx/modules \
            --conf-path=/usr/local/nginx/nginx.conf \
            --error-log-path=/var/log/nginx/error.log \
            --http-log-path=/var/log/nginx/access.log \
            --pid-path=/var/run/nginx.pid \
            --user=nginx \
            --group=nginx \
            --with-http_ssl_module \
            --with-http_realip_module \
            --with-http_auth_request_module \
            --with-http_sub_module \
            --with-http_gzip_static_module \
            --with-http_stub_status_module \
            --with-file-aio \
            --with-threads \
            --with-http_v2_module

最后执行

bash 复制代码
make
make install

查看版本

bash 复制代码
[root@localhost nginx-1.24.0]# nginx -v
nginx version: nginx/1.24.0

即可编辑nginx.conf文件

bash 复制代码
vi /usr/local/nginx/nginx.conf
相关推荐
脏脏a9 分钟前
告别物理出勤:Nginx 搭配 cpolar 实现远程开发无缝协作
运维·nginx
Dxy12393102169 小时前
413 Request Entity Too Large 原因与解决方案
nginx
CYpdpjRnUE10 小时前
光储一体机仿真模型搭建之旅
nginx
Volunteer Technology19 小时前
FastDFS+Nginx
运维·nginx
三水不滴19 小时前
计算机网络核心网络模型
经验分享·笔记·tcp/ip·计算机网络·http·https
SunflowerCoder20 小时前
基于插件化 + Scriban 模板引擎的高效 HTTP 协议中心设计
http·c#
Remember_99321 小时前
MySQL 索引详解:从原理到实战优化
java·数据库·mysql·spring·http·adb·面试
qinyia1 天前
**使用AI助手在智慧运维中快速定位并修复服务异常:以Nginx配置错误导致502错误为例**
linux·运维·服务器·数据库·mysql·nginx·自动化
404Clukay1 天前
Windows Server 配置 Let‘s Encrypt 免费 HTTPS 证书(WACS + Nginx 自动化方案)
windows·nginx·https
Zach_yuan1 天前
从零理解 HTTP:协议原理、URL 结构与简易服务器实现
linux·服务器·网络协议·http