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
相关推荐
赵庆明老师5 小时前
Uniapp微信小程序开发:http请求封装。
http·微信小程序·uni-app
努力的小郑9 小时前
有了TCP为什么还需要HTTP?再用RPC?这次彻底讲明白了
http·微服务·rpc
帅帅梓11 小时前
nginx访问控制 用户认证 https
运维·nginx·https
花花无缺15 小时前
资源泄露问题
java·后端·http
有谁看见我的剑了?19 小时前
k8s ingress-nginx 学习
学习·nginx·kubernetes
moxiaoran575320 小时前
nginx中proxy_pass配置
运维·服务器·nginx
全马必破三1 天前
Node.js HTTP开发
网络协议·http·node.js
IT成长日记1 天前
【Nginx开荒攻略】Nginx虚拟主机配置:从域名、端口到IP的完整指南
linux·运维·服务器·nginx·虚拟主机
爱吃小胖橘1 天前
Unity网络开发--超文本传输协议Http(1)
开发语言·网络·网络协议·http·c#·游戏引擎
杰瑞学AI2 天前
我的全栈学习之旅:FastAPI (持续更新!!!)
后端·python·websocket·学习·http·restful·fastapi