Ubuntu Hardy - Installing Nginx via aptitude

Nginx is a popular lightweight server for those who do not need the bulk and extra services that Apache may offer.

This article will look at installing Nginx on an Ubuntu Hardy Slice using the 'aptitude' package manager.

Using the inbuilt package manager to install packages is a great idea as it solves dependency issues and you are assured of any security updates if, and when, they occur.

However, one drawback can be that it is rare for a version upgrade to be placed into the repositories. As such, it is possible for a newer version of an application to be released and not be placed into the repository.


Using aptitude, Ubuntu Hardy will instal Nginx version 0.5.33.

However, at the time of writing, the latest stable version of Nginx is 0.6.31. You can check the latest versions and change logs at the main nginx site.

Which one you choose is, of course, entirely up to you.

If you decide you would rather have a later version of Nginx than the one aptitude provides, then please refer to the sister article (link on the way) which will take you through the process of installing Nginx from source.

Install and Dependencies

Installing Nginx is incredibly simple as it involves one command:

sudo aptitude install nginx

This will install any and all dependencies that Nginx requires such as libpcre.


One odd thing is that Nginx is not started automatically:

sudo /etc/init.d/nginx start



Now simply navigate to your IP address:

and you will see the wonderfully simple welcome screen:

Nginx Welcome Screen

Init scripts

As you would imagine when installing an application with the aptitude package manager, all init scripts have been created and added to the relevant run levels.

Controlling nginx is done with these commands:

sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart

That's it.


Using the aptitude package manager makes the installation of Nginx and associated dependencies very simple indeed.

The only thing to consider is the version disparity between the one offered by aptitude and the one available via source code.


Article Comments:

Greg Melton commented Mon Sep 15 22:34:55 UTC 2008:

Is it possible to install nginx with build options?


For example:

Is it as simple as going: sudo apt-get install build-dep --with-httpflvmodule

Or, is there something else I need to do?

jake commented Thu Dec 04 03:16:06 UTC 2008:

I tried to set up nginx manually following the PickeledOnion article this one is linked to but I could not complete it do to errors trying to "make" - build error 2. I then decided to use
aptitude install nginx
which worked but the directory structure doesn't seem to be the same as the one as would have been created with the manual install.
For example I do not have a /usr/nginx directory
How do I map the manually created directories to the apt-get directories? This is important as I am trying to set up drupal and I need to alter my some conf files with various paths.

jake commented Thu Dec 04 07:17:16 UTC 2008:

dpkg -L nginx

helps a bit

peter commented Mon Jun 08 10:19:45 UTC 2009:

I have followed the instructions above but when I try to access the site I get connection refused, if I try to get the page from the local machine using wget log:

peter@ubuntu:~$ wget localhost --10:16:50-- http://localhost/ => `index.html' Resolving localhost... Connecting to localhost||:80... failed: Connection refused.

any idea of what might be wrong?

digital perfections commented Thu Nov 12 16:47:38 UTC 2009:

Nice, thanks for the article. You just saved me about an hour (was trying to install from source and having problems).

morris commented Sun Jan 31 23:40:46 UTC 2010:

Thanks for the article - perfect!

Initcron commented Wed Sep 22 17:14:19 UTC 2010:

I have automated ngix setup with php , optimized for wordpress and more. here is my article with the automated script and configs http://www.initcron.org/how-tos/autoinstall-nginx-web-server-with-php-on-ubuntu-10-4-lucid/

Google commented Wed Jul 09 02:03:32 UTC 2014:

No matter if some one searches for his essential thing, thus he/she desires to be available that in detail, so that thing is maintained over here.

win on lotto commented Thu Aug 28 10:19:33 UTC 2014:

Wow, tthis paragraph is pleasant, my sister is analyzing thuese kinds off things, thereforee I am going to convey her.

my homepage; win on lotto

Want to comment?

(not made public)


(use plain text or Markdown syntax)