Many times the packages installed from the Ubuntu repositories are older versions (in some case much older versions) of software. This was the case with PHP where I had to upgrade from version 5.3 to the latest version and now has been the case with the version of Nginx I was running. While short, this article will walk you through the steps I took to upgrade from Nginx version 1.1.19 to the latest stable version 1.4.3 on a server running Ubuntu 12.04 LTS.
Note:Improve your site performance and receive phenomenal support at the same time. For discounted hosting services visit Bluehost.com.
Ubuntu Server Guide
First, you can verify the version of Nginx your server is running by issuing the following command:
1 |
nginx -v |
You should see something like this:
1 |
nginx version: nginx/1.1.19 |
First things first, I recommend backing up your nginx.conf file and your server configuration files if you are upgrading on a live server just in case there is a problem or you answer “yes” in the install to overwrite your current files. Also you will need root access for the rest of the steps.
Step 1 – Stop the Nginx service
1 |
service nginx stop |
Step 2 – add the repository for the stable version of Nginx:
1 |
add-apt-repository ppa:nginx/stable |
Step 3 – get the updates:
1 |
apt-get update |
Step 4 – upgrade Nginx:
1 |
apt-get upgrade |
Step 5 – restart Nginx:
1 |
service nginx start |
That’s all there is to it. To verify you are running the latest version you can run the:
1 |
nginx -v |
command again. You should now see something like this:
1 |
nginx version: nginx/1.4.3 |
If you have problems there are a couple steps you can take. First, for some reason after the initial upgrade on one of my servers I was still showing the previous version of Nginx. In this case I simply rebooted the server and it worked.
If you currently are not running Nginx, and want to install the latest version, there are a couple added steps you will need to take:
Step 1 – install the dependencies
1 2 |
apt-get install python-software-properties apt-get install software-properties-common |
Step 2 – add the stable Nginx repository
1 |
add-apt-repository ppa:nginx/stable |
Step 3 – update the repositories:
1 |
apt-get update |
Step 4 – install Nginx:
1 |
apt-get install nginx |
The final problem you may encounter is an error with “apt-get-repository” not existing. If this is the case you can use the following commands:
Step 1:
1 |
echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu lucid main" > /etc/apt/sources.list.d/nginx-stable-lucid.list |
Step 2:
1 |
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C |
Step 3:
1 |
apt-get update |
Step 4:
1 |
apt-get install nginx |
In all of the above cases the end result should be that you are running the latest version of Nginx.
A good book that has helped me a lot with setting up and configuring Nginx has been .
Jeff Mould
Latest posts by Jeff Mould (see all)
- Laravel 5.4 Redirect after Password Reset Email Sent - September 8, 2017
- How to Fix Laravel 5.2 Token Mismatch Errors - June 30, 2016
- How to Get Sirius XM Deals - May 27, 2016