1.先查看nginx是否启动 ps -C nginx -o pid
2.查看nginx版本,配置记得记下 nginx -V
3.下载新的版本到指定文件夹,可以本地上传或则直接下载 wget http://nginx.org/download/nginx-1.18.0.tar.gz
4.解压 tar xzf nginx-1.18.0.tar.gz
5.进入 cd nginx-1.18.0/
6.设置配置 ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module
7.只make 不要make install make
8.备份原nginx 如 cp /local/nginx/sbin/nginx /local/nginx/sbin/1.16.0nginx
9.关闭ngixn nginx -s stop
10.覆盖原有nginx 如 cp /local/nginx-1.18.0/nginx /usr/nginx/sbin/nginx
11.检测nginx配置 nginx -t
12.检测成功后启动 nginx
13.重新查看版本 nginx -v