(1)查看原有Nginx安装参数:
Shell
[root@prx01 logs]# cd /usr/local/nginx/sbin/
[root@prx01 sbin]# ./nginx -V
1
2[root@prx01logs]# cd /usr/local/nginx/sbin/
[root@prx01sbin]# ./nginx -V
nginx version: nginx/1.9.9
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.2h 3 May 2016
TLS SNI support enabled
configure arguments: –prefix=/usr/local/nginx –user=www –group=www –with-http_stub_status_module –with-http_ssl_module –with-openssl=/usr/local/ssl –with-pcre=/usr/local/src/pcre-8.38 –add-module=/usr/local/src/ngx_cache_purge-2.3 –with-http_gzip_static_module
(2)下载新版本:
下载最新稳定版Nginx到 /usr/local/src 目录
(3)安装新版本:
Shell
[root@prx02 nginx-1.12.2]# cd /usr/local/src
[root@prx02 src]# tar -zxvf nginx-1.12.2.tar.gz
[root@prx02 src]# cd nginx-1.12.2/
1
2
3[root@prx02nginx-1.12.2]# cd /usr/local/src
[root@prx02src]# tar -zxvf nginx-1.12.2.tar.gz
[root@prx02src]# cd nginx-1.12.2/
需要注意的是,如果之前安装过openssl的话需要修改Nginx源码中openssl相关路径:
Shell
[root@prx02 src]# cd /usr/local/src/nginx-1.12.2/auto/lib/openssl/
1[root@prx02src]# cd /usr/local/src/nginx-1.12.2/auto/lib/openssl/
修改conf文件的以下内容:CORE_INCS=”$CORE_INCS $OPENSSL/.openssl/include”
CORE_DEPS=”$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h”
CORE_LIBS=”$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a”
CORE_LIBS=”$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a”
CORE_LIBS=”$CORE_LIBS $NGX_LIBDL”
修改成:CORE_INCS=”$CORE_INCS $OPENSSL/include”
CORE_DEPS=”$CORE_DEPS $OPENSSL/include/openssl/ssl.h”
CORE_LIBS=”$CORE_LIBS $OPENSSL/lib/libssl.a”
CORE_LIBS=”$CORE_LIBS $OPENSSL/lib/libcrypto.a”
CORE_LIBS=”$CORE_LIBS $NGX_LIBDL”
编译安装:
Shell
[root@prx02 nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-openssl=/usr/local/ssl --with-pcre=/usr/local/src/pcre-8.38 --add-module=/usr/local/src/ngx_cache_purge-2.3 --with-http_gzip_static_module
[root@prx02 nginx-1.12.2]# make && make install
1
2
3[root@prx02nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-openssl=/usr/local/ssl --with-pcre=/usr/local/src/pcre-8.38 --add-module=/usr/local/src/ngx_cache_purge-2.3 --with-http_gzip_static_module
[root@prx02nginx-1.12.2]# make && make install
(4)重启nginx:
Shell
[root@prx02 nginx-1.12.2]# service nginx restart
1[root@prx02nginx-1.12.2]# service nginx restart
查看nginx是否启动成功:
Shell
[root@prx02 sbin]# service nginx status
1[root@prx02sbin]# service nginx status
(5)查看Nginx新版本号:
Shell
[root@prx01 logs]# cd /usr/local/nginx/sbin/
[root@prx01 sbin]# ./nginx -V
1
2[root@prx01logs]# cd /usr/local/nginx/sbin/
[root@prx01sbin]# ./nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.2h 3 May 2016
TLS SNI support enabled
configure arguments: –prefix=/usr/local/nginx –user=www –group=www –with-http_stub_status_module –with-http_ssl_module –with-openssl=/usr/local/ssl –with-pcre=/usr/local/src/pcre-8.38 –add-module=/usr/local/src/ngx_cache_purge-2.3 –with-http_gzip_static_module