从官网下载一个新版本的nginx源码包并解压

解压

1
2
[root@localhost ~]# tar zxf nginx-1.13.7.tar.gz
[root@localhost ~]# cd nginx-1.13.7/

编译

1
[root@localhost nginx-1.13.7]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx && make

此处不需要make install

备份配置文件

1
2
[root@localhost nginx-1.13.7]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
[root@localhost nginx-1.13.7]# mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.old

拷贝新配置文件

1
2
3
4
[root@localhost nginx-1.13.7]# cd objs/
[root@localhost objs]# cp nginx /usr/local/nginx/sbin/nginx
[root@localhost nginx-1.13.7]# cd ../conf
[root@localhost conf]# cp nginx.conf /usr/local/nginx/conf/nginx.conf

重新加载

1
nginx -s reload

查看版本号

1
nginx -v