• 幕客老师召集小伙伴
  • python自动化运维项目实战
  • nginx从入门到实战
  • 阿里云与Centos7实战

Nginx平滑升级

一、源码升级

安装基础包:

yum install gcc 

yum install pcre-devel  openssl-devel

 

1、下载软件包

mkdir /opt/download

wget http://nginx.org/download/nginx-1.14.0.tar.gz

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

 

错误解决:

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

Nginx平滑升级

Pingbacks已打开。

引用地址

暂无评论

发表评论