linux升级Nginx1.6到Nginx1.12.2

我的升级环境:
旧版Nginx:1.6
新版Nginx:1.12.2
系统:Redhat 5.5 64位
 
 
前期准备
1、查看Nginx的安装位置
ps -ef |grep nginx  --如果Nginx没在运行,则漏洞为误报,可上报领导。
root     19681(PID号)     1  0 10:44 ?        00:00:00 nginx: master process ./nginx
hgaop    19682 19681  0 10:44 ?        00:00:00 nginx: worker process
root     22014 21985  0 11:14 pts/1    00:00:00 grep nginx
# ll /proc/19681   --513为进程PID号
lrwxrwxrwx 1 hgaop hgaop 0 Mar 2 16:20 cwd -> /data/hgaop/test/nginx/sbin –Nginx启动命令位置,/data/hgaop/test/nginx安装路径
lrwxrwxrwx 1 hgaop hgaop 0 Mar 2 17:07 exe -> /data/hgaop/test/nginx/sbin/nginx
 
2、找出相关文件的位置
find / -name nginx.pid error.log nginx.lock(我的服务器上面没找到) access.log
/data/hgaop/test/nginx/logs/nginx.pid
/data/hgaop/test/nginx/logs/error.log
/data/hgaop/test/nginx/logs/access.log
注意:如果上面找到的文件有些不在安装目录下,则在第四步配置需要指定相关文件的路径,例如:
--pid-path=/data/hgaop/test/nginx/logs/nginx.pid \
--lock-path=/data/hgaop/test/nginx/logs/nginx.lock \
--error-log-path=/data/hgaop/test/nginx/logs/error.log \
--http-log-path=/data/hgaop/test/nginx/logs/access.log \

3、可查看Nginx配置文件,看下端口和网站代码的目录等等,然后用浏览器看是否可以登录
 
升级开始:
一、首先查看一下Nginx版本
/data/hgaop/test/nginx/sbin/nginx -v
 
二、下载最新版本的nginx
网址:Nginxhttp://nginx.org/
 
三、将下载的文件上传到服务器中,解压
tar –zxf nginx-1.12.2.tar.gz
cd /data/nginx-1.12.2
 
四、配置
可用./configure --help查看相关的配置参数,包括制定openssl或者zlib库的路径等等
其中—prefix指定编译的路径。我这里是旧版Nginx的安装路径。告诉编译的Nginx启动文件来这里找nginx.pid,error.log,nginx.lock(我的服务器上面没找到),access.log这四个文件。
./configure \
--user=hgaop \
--group=hgaop \
--prefix=/data/hgaop/test/nginx \
--with-http_stub_status_module \
--with-http_ssl_module
 
五、执行,这里要主要,是只执行make,不能执行make install,切记!!!!!!
# make
 
六、将sbin下的nginx重命名为nginx.old
# mv/data/hgaop/test/nginx/sbin/nginx /data/hgaop/test/nginx/sbin/nginx.old
 
七、复制编译后的objs目录下的nginx到nginx安装目录的sbin下
cd /data/nginx-1.12.2   --执行make的目录
cp objs/nginx /data/hgaop/test/nginx/sbin/
 
八、这里可以测试一下新复制过来的文件是否生效,如果出现下面的 OK 与 successful为正确即可。如下:
# /data/hgaop/test/nginx/sbin/nginx -t
nginx: the configuration file /data/hgaop/test/nginx/conf/nginx.conf syntax is ok nginx: configuration file /data/hgaop/test/nginx/conf/nginx.conf test is successful
可能出现的错误:提示找不到pid,Nginx.conf或者.log文件。
解决:重新在第四步开始。配置要指定pid或者log文件等等(找不到哪个就指定哪个)。如前期准备的第2步说的那样。
 
 
九、停止旧版Nginx,把nginx.pid文件修改成nginx.pid.oldbin,随即重新启动nginx,实现不间断升级。
# cd /data/hgaop/test/nginx/sbin/
# ./nginx.old –s stop  --停止旧版Nginx
# ./nginx --直接回车,启动新版Nginx
 
十、升级完成后,重新查看一下版本即可
# /data/hgaop/test/nginx/sbin/nginx -v
 
十一、去网页访问,网页是否能够打开,查看源代码,看Nginx版本。
 
 
posted @ 2018-03-12 11:13  木与风  阅读(313)  评论(0编辑  收藏  举报