nginx 添加第三方模块或者启用编译时禁用的模块

nginx 添加第三方模块或者启用编译时禁用的模块

最近因为要使用 ngx-http_fastcgi_module 模块的 fastcgi_connect_timeout 参数 遇到的一些问题在此记录下来

问题1:

在Nginx配置中添加 fastcgi_connect_timeout 参数

# fastcgi_connect_timeout 参数 可以添加在  http server localtion 中
# fastcgi_connect_timeout 默认为30s ,格式: fastcgi_connect_timeout 30s;
fastcgi_connect_timeout 60s; 
fastcgi_read_timeout 60s;
fastcgi_send_timeout 60s;

添加参数重启的时候报错:unknown directive "fastcgi_connect_timeout" 识别不了该参数,所以就选择添加第三方模块,或者启用模块

# 使用命令查看,fastcgi模块是否内置模块
cd /data/software/build/nginx-1.18.0
./configure --help | grep fastcgi
  --without-http_fastcgi_module      disable ngx_http_fastcgi_module
  --http-fastcgi-temp-path=PATH      set path to store
                                     http fastcgi temporary files

# 由此看出 ngx-http_fastcgi_module 模块是内置模块 ,所以是之前编译的时候禁用掉了 查看编译参数
/usr/local/webserver/nginx/sbin/nginx -V 
configure arguments: --user=nginx --group=nginx --prefix=/usr/local/webserver/nginx \
--sbin-path=/usr/local/webserver/nginx/sbin/nginx \
--conf-path=/usr/local/webserver/nginx/conf/nginx.conf \
--pid-path=/usr/local/webserver/nginx/run/nginx.pid \
--lock-path=/usr/local/webserver/nginx/run/nginx.lock \
--error-log-path=/usr/local/webserver/nginx/log/nginx/error.log \
--http-log-path=/usr/local/webserver/nginx/log/nginx/access.log \
--with-http_gzip_static_module --with-http_stub_status_module \
--with-http_ssl_module --with-pcre --with-file-aio --with-http_realip_module \
--without-http_scgi_module --without-http_uwsgi_module --without-http_fastcgi_module 
# --without-http_fastcgi_module   --without 表示禁用模块,内置模块没有配置的话,就是默认启用 
# --with-http_v2_module --with  表示添加第三方模块

# 添加或启用模块,需要添加第三方模块的话需要提前下载好,但是启用的话就编译,使用之前的编译信息修改就行。
#删除掉--without-http_fastcgi_module 重新编译
#启用多个模块就删除多个 --without-http_scgi_module --without-http_uwsgi_module --without-http_fastcgi_module 
cd /data/software/build/nginx-1.18.0
./configure --user=nginx --group=nginx --prefix=/usr/local/webserver/nginx \
--sbin-path=/usr/local/webserver/nginx/sbin/nginx \
--conf-path=/usr/local/webserver/nginx/conf/nginx.conf \
--pid-path=/usr/local/webserver/nginx/run/nginx.pid \
--lock-path=/usr/local/webserver/nginx/run/nginx.lock \
--error-log-path=/usr/local/webserver/nginx/log/nginx/error.log \
--http-log-path=/usr/local/webserver/nginx/log/nginx/access.log \
--with-http_gzip_static_module --with-http_stub_status_module \
--with-http_ssl_module --with-pcre --with-file-aio --with-http_realip_module 

# 然后使用make 不用 make install 
make
# make之后会在当前路径的objs文件夹下生成nginx ,使用该文件替换 启动文件nginx
mv /usr/local/webserver/nginx/sbin/nginx /usr/local/webserver/nginx/sbin/nginx.bak
cp objs/nginx /usr/local/webserver/nginx/sbin/
# 查看配置是否正确
/usr/local/webserver/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/webserver/nginx/conf/nginx.conf test is successful
# 重新加载nginx
/usr/local/webserver/nginx/sbin/nginx -s reload
posted @ 2022-03-09 16:37  海中明月  阅读(872)  评论(0编辑  收藏  举报