centos 升级nginx到1.10.2
之前装的是1.6.3版本,准备升级到1.10.2版本。
1、下载nginx1.10.2
wget http://nginx.org/download/nginx-1.10.2.tar.gz
2、解压缩
tar xvf nginx-1.10.2.tar.gz
3、查看当前nginx的模块配置
nginx -V
nginx version: nginx/1.6.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/usr/share/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 --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_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_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_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-pcre --with-pcre-jit --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' --add-module=/root/nginx-sticky
注意,根据nginx官方文档的描述,从1.9.5版本开始,http_spdy_module被替换为http_v2_module了。
4、进入nginx1.10.2目录,修改配置,生成makefile文件:
cd nginx-1.10.2/
./configure --prefix=/usr/share/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 --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_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_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_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-pcre --with-pcre-jit --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' --add-module=/root/nginx-sticky
5、编译
make
make install (如果不执行,报错nginx.pm版本号不对)
6、停止nginx
service nginx stop
7、替换nginx
cp /usr/sbin/nginx /usr/sbin/nginx.bak.20161202
cp ./objs/nginx /usr/sbin/nginx
8、重新启动
service nginx restart
----------------------------------------
如果无法通过service启动或停止nginx,需要配置一下。
1、vim /etc/init.d/nginx #创建nginx的启动,停止,重启的脚本,需要添加如下内容。
注意nginx配置文件的位置,默认是/etc/nginx/nginx.conf,可以改为自己的目录。
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: -
# description: Nginx is an HTTP(S) server, HTTP(S) reverse # proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit nginx="/usr/sbin/nginx"
prog=$(basename $nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx start() {
[ -x $nginx ] || exit
[ -f $NGINX_CONF_FILE ] || exit
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq ] && touch $lockfile
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -TERM
retval=$?
if [ $retval -eq ]; then
if [ "$CONSOLETYPE" != "serial" ]; then
echo -en "\\033[16G"
fi
while rh_status_q
do
sleep
echo -n $"."
done
rm -f $lockfile
fi
echo
return $retval
} restart() {
configtest || return $?
stop
start
} reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
sleep
RETVAL=$?
echo
} configtest() {
$nginx -t -c $NGINX_CONF_FILE
} rh_status() {
status $prog
} rh_status_q() {
rh_status >/dev/null >&
} # Upgrade the binary with no downtime.
upgrade() {
local pidfile="/var/run/${prog}.pid"
local oldbin_pidfile="${pidfile}.oldbin" configtest || return $?
echo -n $"Staring new master $prog: "
killproc $nginx -USR2
sleep
retval=$?
echo
if [[ -f ${oldbin_pidfile} && -f ${pidfile} ]]; then
echo -n $"Graceful shutdown of old $prog: "
killproc -p ${oldbin_pidfile} -TERM
sleep
retval=$?
echo
return
else
echo $"Something bad happened, manual intervention required, maybe restart?"
return
fi
} case "$1" in
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart|configtest)
$
;;
force-reload|upgrade)
rh_status_q || exit
upgrade
;;
reload)
rh_status_q || exit
$
;;
status|status_q)
rh_$
;;
condrestart|try-restart)
rh_status_q || exit
restart
;;
*)
echo $"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart}"
exit
esac
保存并退出
2. chmod +x /etc/init.d/nginx #给予相关的权限
3. /sbin/chkconfig nginx on #添加到开机启动
4. /sbin/chkconfig --list nginx 查看开机启动菜单
5. 如上操作之后就可以使用service nginx start,service nginx stop,service nginx restart等命令、
如果启动失败,看下配置文件是否OK
> nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] mkdir() "/var/lib/nginx/tmp/client_body" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
提示临时目录不存在,手工创建一个:
> mkdir -p /var/lib/nginx/tmp/client_body
> service nginx restart
Restarting nginx (via systemctl): [ OK ]
centos 升级nginx到1.10.2的更多相关文章
- CentOS平滑升级Nginx
服务器:CentOS 6.4 64位 升级方案:nginx1.4.0 – nginx1.4.3 Nginx编译后就一个小文件,不带动态库,升级也可以无缝升级,并不影响访问,按下面的命令执行就可以,具体 ...
- CentOS Mono Nginx 部署 MVC4+WebApi
CentOS Mono Nginx 部署 MVC4+WebApi 经过几天的折磨,终于在CentOS上成功部署了MVC4+WebApi.Mono上的服务器推荐两种:Jexus(国产高人写的一款很牛的服 ...
- 关于centos7和centos6中平滑升级nginx到新版本v1.12.1修复nginx最新漏洞CVE-2017-7529的解决方案
关于centos7和centos6中平滑升级nginx到新版本v1.12.1修复CVE-2017-7529漏洞的解决方案 漏洞描述 2017年7月11日,Nginx官方发布最新的安全公告,在Nginx ...
- 基于centos搭建nginx+uwsgi运行django环境
环境: CentOS 7 nginx/1.9.12 Python 2.7.5 一:安装依赖包5 yum install zlib-devel bzip2-devel pcre-devel openss ...
- CentOS6.5升级内核到3.10.28 --已验证
本文适用于CentOS 6.4, CentOS 6.5,估计也适用于其他Linux发行版. 1. 准备工作 确认内核及版本信息 [root@hostname ~]# uname -r 2.6.32-2 ...
- 升级NGINX支持HTTP/2服务端推送
内容概览 NGINX从1.13.9版本开始支持HTTP/2服务端推送,上周找时间升级了下NGINX,在博客上试验新的特性. 升级工作主要包括: 升级NGINX 修改NGINX配置 修改wordpres ...
- zabbix 3.2.6+centos 7 +nginx 1.12+ mysql 5.6+ Grafana +php 5.6
先只记录关键点 1.nginx.MYSQL 用官方的YUM库安装 2.CENTOS升级到最新 3.ZABBIX 官方RPM安装,然后下载源码库,源码中的PHP复制至NGINX的配置目录 4.NGINX ...
- 如何安装nginx_lua_module模块,升级nginx,nginx-lua-fastdfs-GraphicsMagick动态生成缩略图,实现图片自动裁剪缩放
如何安装nginx_lua_module模块,升级nginx,nginx-lua-fastdfs-GraphicsMagick动态生成缩略图,实现图片自动裁剪缩放 参考网站:nginx-lua-fas ...
- Centos——升级Python2.7及安装pip
CentOS升级Python2.7及安装pip 1) 升级Python2.7 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ...
随机推荐
- DLL入口函数
BOOL APIENTRY DllMain(HINSTANCE hInst /* Library instance handle. */, DWORD reason /* Rea ...
- Django学习笔记第二篇--关于请求获取
#细节都在代码段里面讲解 零.绪论: HTTP协议是一种请求响应的协议,一次请求一次响应.所以这部分的讲解将分为三个部分:请求获取,分析处理.返回响应. 一.获取请求数据: 1.POST和GET类型 ...
- HUD2647 Reward_反向建图拓扑排序
HDU2647 Reward 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2647 题意:老板要发奖金了,有n个人,给你m对数,类似a b,这样的一对 ...
- 删除Android自带的系统软件注意事项
教程类 知识分享 [转]好多童鞋在ROOT手机后,大刀阔斧的就开始砍系统里面的东西,有些事删不得的,删除错了就成砖头了! 以下是对照表: 注意:打*号的千万别删,打-号的是建议删的(大多要穿墙才能 ...
- C# ArcEngine 实现点击要素高亮并弹出其属性
本文是模仿ArcMap里面的Identify(识别)功能,通过点击要素,使其高亮显示并弹出其属性表!本文只做了点击查询! 本文所用的环境为VS2010,AecEngine基于C#语言,界面是用Dev做 ...
- ubuntu重新设置登陆界面|切换gdm kdm lightdm
方法: $ sudo dpkg-reconfigure gdm 然后会出一个让你进行选择的提示,根据需要切换即可
- python基础-第七篇-7.1初识类和对象
创建类和对象 刚开始我们接触得多的编程方式为面向过程编程,这种方式就是根据业务逻辑从上往下垒代码,后来又出现了函数式编程,就是为了提高代码的重用性,减轻程序猿的工作量--而今天我们即将学的 面向对象编 ...
- pipreqs
安装:pip3 install pipreqs 作用:帮你检测当前程序所有的安装模块,并输入到requirements.txt 执行:pipreqs ./ (必须在当前程序目录下) pycharm会 ...
- 剑指Offer——序列化二叉树
题目描述: 请实现两个函数,分别用来序列化和反序列化二叉树 分析: 先序遍历可以用来序列化二叉树,序列化过程中,我们用“0xFFFFFFFF”表示结点为NULL. 反序列化便很简单,遇到“0xFFFF ...
- 优秀Python学习资源收集汇总--强烈推荐(转)
原文:http://www.cnblogs.com/lanxuezaipiao/p/3543658.html Python是一种面向对象.直译式计算机程序设计语言.它的语法简捷和清晰,尽量使用无异义的 ...