ngnix安装ngx_http_lower_upper_case_module模块
1,备份 Nginx 二进制文件
mv /www/server/nginx/sbin/nginx /www/server/nginx/sbin/nginx.bak
2,备份 Nginx 配置文件
cp -r /www/server/nginx/conf /www/server/nginx/conf.bak
3, 下载和解压必要的源码,Nginx、PCRE 和 OpenSSL 的源码
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
cd /usr/local/src https://github.com/replay/ngx_http_lower_upper_case/archive/master.zip(电脑) 上传到 /usr/local/src/ngx_http_lower_upper_case-master mv /usr/local/src/ngx_http_lower_upper_case-master /usr/local/src/ngx_http_lower_upper_case_module(把目录改名为标准模块名)
nginx -V(如果失败则执行下面的命令)
/www/server/nginx/sbin/nginx2.bak -V
cd /data/wwwroot/onlinetest(1.18.0的下载路径)
tar -zxvf nginx-1.18.0.tar.gz
./configure \
–user=www \
–group=www \
–prefix=/www/server/nginx \
–add-module=/www/server/nginx/src/ngx_devel_kit \
–add-module=/www/server/nginx/src/lua_nginx_module \
–add-module=/www/server/nginx/src/ngx_cache_purge \
–add-module=/www/server/nginx/src/nginx-sticky-module \
–with-openssl=/www/server/nginx-1.18.0/openssl-1.1.1g \
–with-pcre=/www/server/nginx-1.18.0/pcre-8.43 \
–with-http_v2_module \
–with-stream \
–with-stream_ssl_module \
–with-stream_ssl_preread_module \
–with-http_stub_status_module \
–with-http_ssl_module \
–with-http_image_filter_module \
–with-http_gzip_static_module \
–with-http_gunzip_module \
–with-ipv6 \
–with-http_sub_module \
–with-http_flv_module \
–with-http_addition_module \
–with-http_realip_module \
–with-http_mp4_module \
–with-ld-opt=’-Wl,-E -ljemalloc’ \
–with-cc-opt=’-Wno-error’ \
–with-http_dav_module \
–add-module=/www/server/nginx/src/nginx-dav-ext-module \
–add-module=/www/server/ngx_brotli \
–add-module=/usr/local/src/ngx_http_lower_upper_case_module
make
(很长时间)
现在我们要把新编译的 nginx 放到宝塔 nginx 的位置
chmod +x /www/server/nginx/sbin/nginx
nginx -t
nginx -s reload
/www/server/nginx/sbin/nginx -V 2>&1 | grep lower
结果:[root@ip-10-0-0-21 nginx-1.18.0]# /www/server/nginx/sbin/nginx -V 2>&1 | grep lower
configure arguments: –user=www –group=www –prefix=/www/server/nginx –add-module=/www/server/nginx/src/ngx_devel_kit –add-module=/www/server/nginx/src/lua_nginx_module –add-module=/www/server/nginx/src/ngx_cache_purge –add-module=/www/server/nginx/src/nginx-sticky-module –with-openssl=/www/server/nginx-1.18.0/openssl-1.1.1g –with-pcre=/www/server/nginx-1.18.0/pcre-8.43 –with-http_v2_module –with-stream –with-stream_ssl_module –with-stream_ssl_preread_module –with-http_stub_status_module –with-http_ssl_module –with-http_image_filter_module –with-http_gzip_static_module –with-http_gunzip_module –with-ipv6 –with-http_sub_module –with-http_flv_module –with-http_addition_module –with-http_realip_module –with-http_mp4_module –with-ld-opt=’-Wl,-E -ljemalloc’ –with-cc-opt=-Wno-error –with-http_dav_module –add-module=/www/server/nginx/src/nginx-dav-ext-module –add-module=/www/server/ngx_brotli –add-module=/usr/local/src/ngx_http_lower_upper_case_module
[root@ip-10-0-0-21 nginx-1.18.0]# top
top – 17:07:52 up 71 days, 12:17, 1 user, load average: 1.39, 1.40, 1.28
Tasks: 191 total, 7 running, 134 sleeping, 0 stopped, 0 zombie
如果 lower_upper指令用不了,要检查
打开源码 /usr/local/src/ngx_http_lower_upper_case_module/ngx_http_lower_upper_case.c,搜索 ngx_command_t,里面会列出模块注册的指令名。
确认到底是 lower_upper、lower_upper_case,还是别的。
static ngx_command_t ngx_http_lower_upper_case_commands[] = { { ngx_string("upper"),
NGX_HTTP_LOC_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE2,
ngx_http_lower_upper_directive, NGX_HTTP_LOC_CONF_OFFSET, 0, NULL }, { ngx_string("lower"),
NGX_HTTP_LOC_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE2,
ngx_http_lower_upper_directive, NGX_HTTP_LOC_CONF_OFFSET, 0, NULL }, ngx_null_command };
你贴出的源码片段已经揭示了关键点:
模块注册的指令并不是 lower_upper,而是 lower 和 upper。
Leave a Reply
You must be logged in to post a comment.