Nginx平滑升级

263 阅读1分钟

一、下载nginx

下载1.26.0的nginx

nginx.org/download/ng…

二、上传至服务器

使用SSH软件上传至指定服务器的指定路径下

三、解压文件包

tar -zxvf /root/new/nginx-1.26.0.tar.gz

四、进入解压后的nginx文件目录

cd /root/new/nginx-1.26.0

五、获取旧版nginx配置

## 查看nginx的配置信息
/root/old/nginx -V

六、配置新版nginx

./configure {第五步输出的配置信息}

七、编译nginx

## 使用make而不是make install
make

八、备份旧版nginx

cp /root/old/nginx /root/old/nginx.old

九、替换旧版nginx

cp -f ./objs/nginx /root/old/nginx

十、平滑升级

make upgrade

附、配置时一些异常信息Q&A

Q:

checking for C compiler ... not found

./configure: error: C compiler cc is not found

A:

yum install gcc-c++

Q:

checking for gcc -pipe switch ... found
checking for --with-ld-opt="-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E" ... not found

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

A:

 yum install redhat-rpm-config

Q:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

A:

yum install pcre-devel  openssl-devel

Q:

./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.

A:

yum install libxslt-devel

Q:

./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.

A:

yum install gd-devel

Q:

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

A:

yum install perl-ExtUtils-Embed

Q:

./configure: error: the Google perftools module requires the Google perftools
library. You can either do not enable the module or install the library.

A:

yum install gperftools-devel