Well at first installation i used nginx v0.7.63 and the latest stable as i write this post is v0.8.53. There are lot of changes and bug fixes. So i decided to upgrade it to the latest one.
Nginx can be upgrade without downtime, to do that please follow the steps below:
- First login as root to your server via SSH.
- Download the latest nginx package:
cd /usr/src #working directory wget http://nginx.org/download/nginx-0.8.53.tar.gz
- Make backup if your old nginx binary (just to be safe):
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.old
- Install the new nginx:
cd /usr/src tar xvzf nginx-0.8.53.tar.gz cd nginx-0.8.53 ./configure --with-http_ssl_module --with-http_realip_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module make make install
- Run the new nginx binary simultaneously with the old one without killing the old one yet:
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
note: this command will send a USR2 signal to the current pid file, as the result is nginx master process will rename its pid and start the new binary.
- Check the process is:
ps aux | grep nginx
in this case my old nginx process id is 15651.
- So i want to shutdown the old process, don’t instantly kill it with ‘-9′, instead use WINCH:
kill -WINCH 15651
- Now test your website, and see if it is working as it is. If no problem or error, now kill the old nginx process:
kill -QUIT 15651
- Now your nginx has been upgraded.
As the result of this change is not that much i can feel. But just to be secured and have an latest update technology is one way to secure your server and learning a new thing. I have a hungry mind to feed, so i did this. Hope you like it.
After upgrade nginx version still showing up as 1.0.12 when I type: