nginx-1.24编译安装

1.创建压缩包存放路径

复制代码
[root@localhost /]# mkdir -p /apps/scripts
[root@localhost /]# cd apps/scripts/

2.上传所需文件

3.初始化环境

复制代码
[root@localhost scripts]# yum install -y yum-utils device-mapper-persistent-data lvm2 wget net-tools nfs-utils lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip sudo libaio-devel wget vim ncurses-devel autoconf automake zlib-devel  python-devel epel-release openssh-server socat  ipvsadm conntrack telnet ipvsadm vim

4.压缩包解压

复制代码
[root@localhost scripts]# tar -zxf nginx-1.24.0.tar.gz 
[root@localhost scripts]# tar -zxf nginx-module-vts-0.2.2.tar.gz 
[root@localhost scripts]# tar -zxf ngx_brotli.tgz 
[root@localhost scripts]# tar -zxf openssl-1.1.1w.tar.gz 
[root@localhost scripts]# tar -zxf pcre-8.45.tar.gz 
[root@localhost scripts]# tar -zxf zlib-1.3.tar.gz 
[root@localhost scripts]# unzip nginx-sticky-module-ng-08a395c66e42.zip 
[root@localhost scripts]# unzip ngx_http_proxy_connect_module-master.zip

5.检测编译环境 加模块

复制代码
[root@localhost scripts]# cd /apps/scripts/nginx-1.24.0
[root@localhost nginx-1.24.0]# ./configure --prefix=/apps/nginx --modules-path=/apps/nginx/modules --with-compat --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_ssl_preread_module --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-zlib=/apps/scripts/zlib-1.3  --with-pcre=/apps/scripts/pcre-8.45  --with-openssl=/apps/scripts/openssl-1.1.1w  --add-module=/apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42  --add-module=/apps/scripts/nginx-module-vts-0.2.2 --add-module=/apps/scripts/ngx_brotli  

6.编译

复制代码
[root@localhost nginx-1.24.0]# make

出现报错,详细如下:

复制代码
/apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c: In function 'ngx_http_init_sticky_peer':
/apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c:207:54: error: 'ngx_http_headers_in_t' has no member named 'cookies'
  if (ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &iphp->sticky_conf->cookie_name, &route) != NGX_DECLINED) {
                                                      ^
/apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c:207:2: error: passing argument 2 of 'ngx_http_parse_multi_header_lines' from incompatible pointer type [-Werror]
  if (ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &iphp->sticky_conf->cookie_name, &route) != NGX_DECLINED) {
  ^
In file included from /apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c:9:0:
src/http/ngx_http.h:106:18: note: expected 'struct ngx_table_elt_t *' but argument is of type 'struct ngx_str_t *'
 ngx_table_elt_t *ngx_http_parse_multi_header_lines(ngx_http_request_t *r,
                  ^
/apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c:207:2: error: too few arguments to function 'ngx_http_parse_multi_header_lines'
  if (ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &iphp->sticky_conf->cookie_name, &route) != NGX_DECLINED) {
  ^
In file included from /apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c:9:0:
src/http/ngx_http.h:106:18: note: declared here
 ngx_table_elt_t *ngx_http_parse_multi_header_lines(ngx_http_request_t *r,
                  ^
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.o] Error 1
make[1]: Leaving directory `/apps/scripts/nginx-1.24.0'
make: *** [build] Error 2

7.报错处理

查询相关资料,该报错可能是因为nginx版本与ngx_http_proxy_connect_module-master中patch版本不符导致。以下为版本对应图:

参考上述对应图,部署nginx-1.24需指定为proxy_connect_rewrite_102101.patch

安装patch命令

root@localhost nginx-1.24.0\]# yum -y install patch.x86_64 \[root@localhost nginx-1.24.0\]# patch -p1 \< /apps/scripts/ngx_http_proxy_connect_module-master/patch/proxy_connect_rewrite_102101.patch ![在这里插入图片描述](https://file.jishuzhan.net/article/1765348805890281473/ded4c811ca2cf3263c26e2b6c1d36092.webp) 再次:检测编译环境 加模块及编译 依旧报错: /apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c: In function 'ngx_http_init_sticky_peer': /apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c:207:54: error: 'ngx_http_headers_in_t' has no member named 'cookies' if (ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &iphp->sticky_conf->cookie_name, &route) != NGX_DECLINED) { ^ /apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c:207:2: error: passing argument 2 of 'ngx_http_parse_multi_header_lines' from incompatible pointer type [-Werror] if (ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &iphp->sticky_conf->cookie_name, &route) != NGX_DECLINED) { ^ In file included from /apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c:9:0: src/http/ngx_http.h:106:18: note: expected 'struct ngx_table_elt_t *' but argument is of type 'struct ngx_str_t *' ngx_table_elt_t *ngx_http_parse_multi_header_lines(ngx_http_request_t *r, ^ /apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c:207:2: error: too few arguments to function 'ngx_http_parse_multi_header_lines' if (ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &iphp->sticky_conf->cookie_name, &route) != NGX_DECLINED) { ^ In file included from /apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.c:9:0: src/http/ngx_http.h:106:18: note: declared here ngx_table_elt_t *ngx_http_parse_multi_header_lines(ngx_http_request_t *r, ^ cc1: all warnings being treated as errors make[1]: *** [objs/addon/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ngx_http_sticky_module.o] Error 1 make[1]: Leaving directory `/apps/scripts/nginx-1.24.0' make: *** [build] Error 2 ![在这里插入图片描述](https://file.jishuzhan.net/article/1765348805890281473/952502da7423ad2d2839c7e5190fe2ee.webp) 继续查询相关资料,有一种思路为替换配置文件,尝试一下是否可行 [root@localhost nginx-1.24.0]# cd /apps/scripts/nginx-goodies-nginx-sticky-module-ng-08a395c66e42/ [root@localhost nginx-goodies-nginx-sticky-module-ng-08a395c66e42]# sed -i "s/ngx_http_parse_multi_header_lines.*/ngx_http_parse_multi_header_lines(r, r->headers_in.cookie, \&iphp->sticky_conf->cookie_name, \&route) != NULL){/g" ngx_http_sticky_module.c 再次:检测编译环境 加模块及编译 ![在这里插入图片描述](https://file.jishuzhan.net/article/1765348805890281473/553da83c0d3977c1a9e7e8347f1aca5e.webp) 方法可行,没有报错了 8.安装 [root@localhost nginx-1.24.0]# make install ![在这里插入图片描述](https://file.jishuzhan.net/article/1765348805890281473/762fcf2a4ed85b514811e0a3d76e1fa3.webp) 9.验证 ![在这里插入图片描述](https://file.jishuzhan.net/article/1765348805890281473/9b7ef1e1eeb09021cd23b839193e03b5.webp)

相关推荐
cxr8285 小时前
自动化知识工作AI代理的工程与产品实现
运维·人工智能·自动化
·云扬·5 小时前
从零开始搭 Linux 环境:VMware 下 CentOS 7 的安装与配置全流程(附图解)
linux·运维·centos
btyzadt8 小时前
虚拟机蓝屏问题排查与解决
linux·运维·网络
G_H_S_3_9 小时前
【网络运维】Shell 脚本编程:while 循环与 until 循环
linux·运维·网络·shell
张鱼小丸子10 小时前
MySQL企业级部署与高可用实战
运维·数据库·mysql·云原生·高可用·mha·组从复制
时空自由民.11 小时前
linux下camera 详细驱动流程 OV02K10为例(chatgpt版本)
linux·运维·服务器
云川之下11 小时前
【网络】使用 DNAT 进行负载均衡时,若未配置配套的 SNAT,回包失败
运维·网络·负载均衡
ManageEngineITSM12 小时前
云原生环境下的ITSM新趋势:从传统运维到智能化服务管理
大数据·运维·人工智能·云原生·itsm·工单系统
檀越剑指大厂12 小时前
【Nginx系列】查看 Nginx 的日志
运维·nginx
byte轻骑兵14 小时前
【Linux文件系统】Linux文件系统与设备驱动
linux·运维·服务器