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
相关推荐
一颗青果6 小时前
HTTP协议详解
linux·网络·网络协议·http
Joy T8 小时前
【AI运维】02 云上基础部署:ECS、OSS 与 Nginx 的体系化理解与实践
运维·nginx
Dreamboat-L9 小时前
云服务器上部署nginx
java·服务器·nginx
季__末11 小时前
WSL2安装配置
nginx
talenteddriver17 小时前
Java Web:http请求在springboot项目中的传递层级(自用笔记)
java·前端·spring boot·http
登山人在路上19 小时前
Nginx负载均衡策略
服务器·nginx·负载均衡
bkspiderx19 小时前
HTTP跨域问题深度解析:4种实用解决方案与场景适配
网络·http·nginx反向代理·cors·跨域资源共享·http跨域问题
雪域迷影19 小时前
使用Python库获取网页时报HTTP 403错误(禁止访问)的解决办法
开发语言·python·http·beautifulsoup·urllib
不染尘.1 天前
DHCP和HTTP2_3
服务器·网络·网络协议·计算机网络·http·udp·tcp
刘火锅1 天前
Nginx HTTP基本认证配置技术文档
运维·nginx·http