Nginx如何進行平滑升級

mug發表於2021-09-09

一、原始碼升級

1、安裝基礎包:

yum install gcc 

yum install pcre-devel  openssl-devel


2、下載軟體包

mkdir /opt/download

wget

nginx -V

複製nginx -V 的結果進行輸出編譯


./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_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-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

make -j 2

make install

3、重啟Nginx程式

nginx -tc /etc/nginx/nginx.conf

nginx -s reload -c /etc/nginx/nginx.conf



錯誤解決:

1、編譯錯誤

./configure: error: the invalid value in --with-ld-opt="-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E"

解決:

yum install redhat-rpm-config

2、編譯錯誤2

./configure: error: the HTTP XSLT module requires the libxml2/libxslt

libraries. You can either do not enable the module or install the libraries.

解決:

yum install libxslt-devel

3、編譯錯誤3


./configure: error: the HTTP image filter module requires the GD library.

You can either do not enable the module or install the libraries.

解決:

yum install gd-devel

4、編譯錯誤4


./configure: error: perl module ExtUtils::Embed is required

解決:

yum install perl-ExtUtils-Embed


5、編譯錯誤5


./configure: error: the GeoIP module requires the GeoIP library.

You can either do not enable the module or install the library.

解決:

yum install geoip-devel


6、編譯錯誤6

./configure: error: the Google perftools module requires the Google perftools

library. You can either do not enable the module or install the library.

解決:

yum install gperftools-devel


7、編譯工程師


./configure: warning: the "--with-ipv6" option is deprecated

原因:

系統已經關閉了ipv6

[root@Centos7-aliyunECS nginx-1.14.0]# sysctl -p

net.ipv6.conf.all.disable_ipv6 = 1

net.ipv6.conf.default.disable_ipv6 = 1

net.ipv6.conf.lo.disable_ipv6 = 1


8、啟動nginx時候報錯


# nginx -tc /etc/nginx/nginx.conf


nginx: [alert] version 1.12.2 of nginx.pm is required, but 1.14.0 was found

原因:在升級nginx時候,/usr/local/lib64/perl5目錄下已經存在了nginx.pm,它裡面記錄了nginx的版本號。所以,如果啟動nginx的時候,執行的nginx與nginx.pm版本號不一致就有問題,特別是升級nginx,或者一臺機器上部署了多個nginx。

解決辦法:


rm -rf  /usr/local/lib64/perl5/nginx.pm


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/506/viewspace-2813171/,如需轉載,請註明出處,否則將追究法律責任。

相關文章