使用未配置的模块会产生nginx: [emerg] unknown directive "sub_filter_types"之类的错误提示。
查看当前配置
[root@localhost sbin]# ./nginx -V # 输入查看版本命令
nginx version: nginx/1.26.0
built by gcc 7.3.0 (GCC)
built with OpenSSL 1.1.1f 31 Mar 2020
TLS SNI support enabled
configure arguments: --prefix=/usr/local/app/nginx --with-http_ssl_module
修改配置
进入原来的源码包,如果找不到了可以下载版本相同的源码包。
[root@localhost nginx-1.26.0]# ./configure --prefix=/usr/local/app/nginx --with-http_ssl_module --with-http_sub_module
checking for OS
+ Linux 4.19.90-52.22.v2207.ky10.aarch64 aarch64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 7.3.0 (GCC)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
......
......
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/Makefile
Configuration summary
+ using system PCRE2 library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/app/nginx"
nginx binary file: "/usr/local/app/nginx/sbin/nginx"
nginx modules path: "/usr/local/app/nginx/modules"
nginx configuration prefix: "/usr/local/app/nginx/conf"
nginx configuration file: "/usr/local/app/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/app/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/app/nginx/logs/error.log"
nginx http access log file: "/usr/local/app/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
重新编译
[root@localhost nginx-1.26.0]# make
make -f objs/Makefile
make[1]: 进入目录“/usr/local/app/nginx-1.26.0”
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I objs \
-o objs/src/core/nginx.o \
src/core/nginx.c
......
......
objs/ngx_modules.o \
-ldl -lpthread -lcrypt -lpcre2-8 -lssl -lcrypto -ldl -lpthread -lz \
-Wl,-E
sed -e "s||/usr/local/app/nginx|" \
-e "s||/usr/local/app/nginx/logs/nginx.pid|" \
-e "s||/usr/local/app/nginx/conf/nginx.conf|" \
-e "s||/usr/local/app/nginx/logs/error.log|" \
< man/nginx.8 > objs/nginx.8
make[1]: 离开目录“/usr/local/app/nginx-1.26.0”
替换新文件
进入sbin文件夹,执行./nginx -s stop停止Nginx服务。然后备份文件,再将新的编译文件复制进来。
# 进入原来的编译文件目录
cd /usr/local/app/nginx/sbin
# 停止服务
./nginx -s stop
# 备份原编译文件
mv nginx nginx_bak
# 将新编译文件复制进来
cp /usr/local/app/nginx-1.26.0/objs/nginx .
检查配置
[root@localhost sbin]# ./nginx -V # 输入查看版本命令
nginx version: nginx/1.26.0
built by gcc 7.3.0 (GCC)
built with OpenSSL 1.1.1f 31 Mar 2020
TLS SNI support enabled
configure arguments: --prefix=/usr/local/app/nginx --with-http_ssl_module --with-http_sub_module