Nginx编译

通过Ps命令查看 Nginx文件的路径

ps -elf | grep nginx

返回以下信息

5 S root     24002     1  0  80   0 - 32975 sigsus 11:05 ?        00:00:00 nginx: master process /www/server/nginx/sbin/nginx -c /www/server/nginx/conf/nginx.conf
5 S www      27093 24002  0  80   0 - 41176 ep_pol 11:28 ?        00:00:00 nginx: worker process
5 S www      27094 24002  0  80   0 - 33464 ep_pol 11:28 ?        00:00:00 nginx: cache manager process
0 R root     27948 27864  0  80   0 - 28203 -      11:35 pts/0    00:00:00 grep --color=auto nginx

[scode type="yellow"] 以下所有步骤都以 自身Nginx路径和信息为准[/scode]

使用 Cd 命令进去文件目录

cd /www/server/nginx/sbin/

然后查看当前 Nginx编译的参数

nginx -V

返回以下信息

nginx version: Sajuna/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.1.1g  21 Apr 2020
TLS SNI support enabled
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/src/openssl --with-pcre=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 --with-cc-opt=-Wno-error --with-ld-opt=-ljemalloc --with-http_dav_module --add-module=/www/server/nginx/src/nginx-dav-ext-module

./configure arguents:之后的内容复制下来,在最前面添加./configure

./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/src/openssl --with-pcre=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 --with-cc-opt=-Wno-error --with-ld-opt=-ljemalloc --with-http_dav_module --add-module=/www/server/nginx/src/nginx-dav-ext-module

利用Cd命令进入文件目录

cd /www/server/nginx/src

执行你修改好的 ./configure命令

然后重新安装

make && make install

最后重启 Nginx

service nginx restart

文章来源:

Author:朱茱
link:https://www.isajuna.com/archives/14/