Tutorial

How To Install The Latest Version Of Nginx On Ubuntu 12.10

Published on April 30, 2013
author

Rob Brazier

How To Install The Latest Version Of Nginx On Ubuntu 12.10

Status: Deprecated

This article is deprecated and no longer maintained.

Reason

Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates.

See Instead

This article may still be useful as a reference, but may not follow best practices or work on this or other Ubuntu releases. We strongly recommend using a recent article written for the version of Ubuntu you are using.

If you are currently operating a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

About Nginx

Nginx is a free, Open Source Web server. It is much more lightweight than Apache and it can be used as the main web server software or be set up as a reverse proxy for Apache.

Setup

Before using this tutorial, you will need to SSH into your VPS, by typing into the terminal: ssh <user>@<server_ip>. The user will need to either be in root or have root privileges, otherwise the commands entered below may not work.

Step One - Installing Dependencies

The packages that you will need to install are python-software-properties and software-properties-common (which is only necessary if you are running Ubuntu 12.10).

To install the first package dependency, python-software-properties, you will need to run the following command:

sudo apt-get install python-software-properties

If you are on Ubuntu 12.10, you should run the following command to install software-properties-common, which is another package that is necessary (without it, the add-apt-repository command used in Step Two will not be found).

sudo apt-get install software-properties-common

Step Two - Adding the Stable Nginx Repository

To ensure that our web server software is secure to run on a VPS, we will be using the latest ‘stable’ release.

If you are developing a nginx module, or if you need to use the “bleeding edge” version, you can replace the ‘stable’ version with the ‘development’ version. However I would not recommend doing this on a VPS, as there may be bugs.

Now that we have the latest stable package installed, we can now add the repository to install the latest version of nginx:

sudo add-apt-repository ppa:nginx/stable

Note: If this command still does not work (normally on 12.10), run the following command:

sudo apt-get install software-properties-common

This will add the repository to Ubuntu and fetches the repository’s key. This is to verify that the packages have not been interfered with since they have been built.

Step Three - Updating the Repositories

After adding a new repository, you will need to update the list:

sudo apt-get update

Step Four - Install nginx

To install nginx or update the version you already have installed, run the following command:

sudo apt-get install nginx

Step Five - Check That Nginx is Running

You can check to see that nginx is running by either going to your VPS’ IP address/domain, or typing in:

service nginx status

This will tell you whether nginx is currently running.

(Step Six - if Nginx is Not Running)

If nginx is not running correctly, and/or prints out an error e.g. nginx: [emerg] bind() to [::]:80 failed (98: Address already in use), you can run:

netstat -tulpn

This will list all processes listening on ports. You should see something like this:

The highlighted number, the PID, is the number that you will use to kill the process. In this case, you would need to run kill -9 734. However the general code to copy into your terminal would be:

kill -9 xxxx

The phrase, “xxxx”, is the PID of the process you want to kill. After killing the process, you can try restarting nginx again by running:

service nginx start

Alternatively, the issue may be caused by the configuration accepting connections from both ipv4 and ipv6. In order to resolve this, edit out “listen [::]:80” in your default config file (/etc/nginx/sites-available/default) and any other server block config files that are in use.

sudo nano /etc/nginx/sites-available/default

The lines should look like this:

server {
        listen 80;
        #listen [::]:80 default_server;

Note:

You can view more information about the PPA release from: https://launchpad.net/~nginx/+archive/stable

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Rob Brazier

author

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
10 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

I have updated using this tutorial, but I can not reload or restart nginx now. As a result I can not change some settings, like enable gzip. Nginx itself is somehow running and serving my website. Complete server Restart didn’t solve the problem. Any suggestions?

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
May 26, 2014

@Adriano: Yes, the same commands should work just fine.

Can I update nginx to its latest version if I’m on ubuntu 12.04 LTS?

Txt in advance!

I’m trying to update nginx on my server (it’s at 1.1.19) and I know that it can be at 1.4.4 at least. I ran through the steps and it’s telling me it’s the latest version, even though it’s still at 1.1.19.

Is there something I’m missing? I’m on Ubuntu 12.04.3

Thanks, leo! I’ve had nginx 1.2.1 on Ubuntu 12.10. I’ve done: apt-get remove nginx-full nginx and then: apt-get install nginx-full and everything is working fine now.

Just a heads up… dunno why my ubuntu came with nginx 1.2 installed… i had to remove nginx-full to install the new version…

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
November 22, 2013

@jijo: Are you sure you removed apache? Try running <pre>sudo apt-get remove apache2*</pre>

Rebooted. Still Apache appears. :/

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.