Upgrade Nginx to the latest version on Ubuntu

What’s the need for upgrade Nginx

If you are running older nginx version in ubuntu then you need to upgrade nginx to latest stable version as older version have some security measures. The default version of nginx with ubuntu is good but it’s old.  For example, the most popular version in use right now is 12.04 LTS Precise Pangolin, and it ships with Nginx version 1.1.19. So you should update it to latest version which is now 1.8.0.

You can check the nginx changelog here – http://nginx.org/en/CHANGES

So the first thing you need to check your current version of nginx. In my case it’s 1.4.7

root@linuxtweaks ~]#nginx -v
nginx version: nginx/1.4.7

Now you need to take backup of your nginx configuration in case anything wrong happen with your setup.

root@linuxtweaks ~]#sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf_oldversion

After that you have to stop nginx service.

root@linuxtweaks ~]# service nginx stop

Upgrade Nginx

Install the dependencies

root@linuxtweaks ~]#sudo aptitude install python-software-properties

Add the repository for the stable version of Nginx in your server.

root@linuxtweaks ~]#sudo add-apt-repository ppa:nginx/stable

Now finally you can update your repository and upgrade your system with latest nginx

sudo aptitude update
sudo aptitude safe-upgrade

NOTE:  it ask you if you want to keep older configuration or latest configuration this is up to you just keep in mind if you press “Y” then it would install latest configuration then you need to update it with your older configuration in case you tweaks something previously as per your site.

The above whole process automatically upgrade your nginx and restart it. if everything goes normal then you should have latest version of nginx in your system.

root@linuxtweaks ~]# nginx -V
nginx version: nginx/1.8.0

Check your website if it’s running normal.

View more posts in this category !!!

Click here to setup HTTP Authentication with Nginx on Ubuntu

What’s the need for upgrade Nginx

If you are running older nginx version in ubuntu then you need to upgrade it to latest stable version as older version have some security measures. The default version of nginx with ubuntu is good but it’s old.  For example, the most popular version in use right now is 12.04 LTS Precise Pangolin, and it ships with Nginx version 1.1.19. So you should update it to latest version which is now 1.8.0.

You can check the nginx changelog here – http://nginx.org/en/CHANGES

So the first thing you need to check your current version of nginx. In my case it’s 1.4.7

root@linuxtweaks ~]#nginx -v
nginx version: nginx/1.4.7

Now you need to take backup of your nginx configuration in case anything wrong happen with your setup.

root@linuxtweaks ~]#sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf_oldversion

After that you have to stop nginx service.

root@linuxtweaks ~]# service nginx stop

Upgrade Nginx

Install the dependencies

root@linuxtweaks ~]#sudo aptitude install python-software-properties

Add the repository for the stable version of Nginx in your server.

root@linuxtweaks ~]#sudo add-apt-repository ppa:nginx/stable

Now finally you can update your repository and upgrade your system with latest nginx

sudo aptitude update
sudo aptitude safe-upgrade

NOTE:  it ask you if you want to keep older configuration or latest configuration this is up to you just keep in mind if you press “Y” then it would install latest configuration then you need to update it with your older configuration in case you tweaks something previously as per your site.

The above whole process automatically upgrade your nginx and restart it. if everything goes normal then you should have latest version of nginx in your system.

root@linuxtweaks ~]# nginx -V
nginx version: nginx/1.8.0

Check your website if it’s running normal.

View more posts in this category !!!

Click here to setup HTTP Authentication with Nginx on Ubuntu

Click here to Install Nginx with Pagespeed in CentOs or RedHat

Click here to Install Nginx with Pagespeed in Ubuntu from Source

Click here to Install Varnish in front of Nginx Proxy web server in CentOS/RedHat

Click here to Install Nginx with Pagespeed in CentOs or RedHat

Click here to Install Nginx with Pagespeed in Ubuntu from Source

Click here to Install Varnish in front of Nginx Proxy web server in CentOS/RedHat

 

Balvinder Singh

Hello, I am Balvinder Singh - DevOps Engineer with 2.5+ year of working experience with different server environments. Tag Line:-Linux | AWS| WHM |Monitoring | Virtualization | Optimization | Performance | Security | Release & Deployment. I love helping companies / clients to deploy their code / applicateions to well managed, optimized, secure server and can go extra mile to satisfy.

You may also like...

Leave a Reply

Your email address will not be published.