It’s important to keep your Nginx server up when you try to upgrade your Nginx to a newer version. I tried following steps successfully.

  1. Check the compile configuration for previous version:
/usr/local/nginx/sbin/nginx -V
  1. Configure the new version according to the previous configuration and your need.

  2. Compile and install

make & make install
  1. Send USR2(12) signal to the master process:
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`

A new file name nginx.pid.oldbin appeared in /usr/local/nginx/logs/.

  1. Send WINCH(28) signal to master process in order to shutdown the worker process gracefully:
kill -WINCH `cat /usr/local/nginx/logs/nginx.pid.oldbin`
  1. Send QUIT signal to shutdown the master process:
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`

Now the nginx server should have been upgraded gracefully.