码迷,mamicode.com
首页 > 系统相关 > 详细

ubuntu中升级nginx到最新版本

时间:2016-03-13 14:09:37      阅读:471      评论:0      收藏:0      [点我收藏+]

标签:

#系统信息

lsb_release -a

No LSB modules are available.

Distributor ID:                 Ubuntu

Description: Ubuntu 14.04.4 LTS

Release:      14.04

Codename: trusty

 

#下载最新版nginx (截至2016-3-13最新版为1.9.12)

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

#解压

tar zxvf nginx-1.9.12.tar.gz

cd nginx-1.9.12

 

#查看原来的nginx信息

nginx -V

nginx version: nginx/1.8.1

built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)

built with OpenSSL 1.0.1f 6 Jan 2014

TLS SNI support enabled

configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --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_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-cc-opt=‘-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2‘ --with-ld-opt=‘-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed‘ --with-ipv6

 

# .执行configure命令,后面跟上原来nginx的配置

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --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_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-cc-opt=‘-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2‘ --with-ld-opt=‘-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed‘ --with-ipv6

 

错误1

./configure: error: invalid option "--with-http_spdy_module"

根据官方文档说明需要修改为

--with-file-aio --with-http_v2_module

参考: (http://www.klfy.net/blog/636.shtml)

 

错误2

./configure: error: the HTTP rewrite module requires the PCRE library.

rewrite需要pcre支持,

apt-get install libpcre3 libpcre3-dev

 

#重新生成makefile

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --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_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-cc-opt=‘-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2‘ --with-ld-opt=‘-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed‘ --with-ipv6 

 

#编译

make

会在objs/目录下 编译生成nginx

objs/nginx -v

nginx version: nginx/1.9.12

 

 

#备份原来的nginx到nginx1.8.1

mv /usr/sbin/nginx /usr/sbin/nginx1.8.1 

#复制新的nginx到/usr/sbin/nginx

cp objs/nginx /usr/sbin/nginx

 

#升级命令

make upgrade 

/usr/sbin/nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

kill -USR2 `cat /var/run/nginx.pid`

sleep 1

test -f /var/run/nginx.pid.oldbin

kill -QUIT `cat /var/run/nginx.pid.oldbin`

 

#查看版本

nginx -v

nginx version: nginx/1.9.12

 

#检查配置信息

/usr/sbin/nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

 

#重启nginx

 nginx -s reload

 技术分享

个人笔记

ubuntu中升级nginx到最新版本

标签:

原文地址:http://www.cnblogs.com/shiv/p/5271711.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!