Debian Etch - installing nginx

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

Unfortunately, Debian Etch comes with rather an old version (0.4.13). As such, let's look at installing the latest stable version of nginx from source.


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


As we are not using the package manager to install nginx, we need to take care of some dependencies.

Not many are needed and include pcre, ssl and zlib packages:

sudo aptitude install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev


Now we can download the source code. Move into your sources directory:

cd ~/sources/

And then download the source code:



Unpack the downloaded tar file and move into the newly created directory:

tar -zxvf nginx-0.5.32.tar.gz
cd nginx-0.5.32/


There are quite a few compile time options that are available to use.

Have a look at the Install Options page of the nginx wiki for full details.

We're going to use just two options to customise the install. The first of which is:


By default, nginx will be installed in /usr/local/nginx which, although a good place, does mean the main nginx binary will be found in /usr/local/nginx/sbin/nginx.

Not a location we are likely to find in our default search paths. So instead of adding new directories to our path (which may cause errors later on) we simply define where to put the binary.

The second option is:


Probably self explanatory, but this will enable the ssl module to be compiled so we can parse https requests.


Let's go ahead and compile nginx using those two options:

./configure --sbin-path=/usr/local/sbin --with-http_ssl_module

There will be a nice summary at the end of the compile which includes such items as:

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/sbin"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"

Keep a note of the output as it does contain some useful paths and locations for various files.


Ok, let's go ahead and 'make' and then 'make install':

sudo make install


Done. We can test the install by starting nginx:

sudo /usr/local/sbin/nginx

and navigating to our Slice IP address (assuming you have no other server running):

You will be greeted with the standard welcome page:

Nginx Welcome Screen


If you have used Apache or some other web server, you may be used to using a script to start and stop it such as you might find in '/etc/init.d'.

Unfortunately, nginx doesn't come with a script like that (the next article will deal with creating such a script).

You may have noticed that one of the paths noted in the compile summary was:

nginx pid file: "/usr/local/nginx/logs/"

Let's make use of that to stop nginx:

sudo kill `cat /usr/local/nginx/logs/`

That will use the output of the pid file to kill the nginx process - note the use of backslashes (`) and not single quotes (') in the command.


Although quite detailed, we have installed the latest version of nginx from source and compiled it with some custom options to make life slightly easier.

We also know how to start and stop nginx by hand. As mentioned, the next article will deal with creating an init script so we have more control over the server.

Once done, we will then look at configuring nginx, setting up vhosts and proxying to a backend (such as a cluster of mongrels).


Article Comments:

Lynton Morgan commented Fri Jan 11 00:20:37 UTC 2008:

Hi there. I could not make this work on my debian install with the latest version of nginx. I had problems with an out of date lib6c version as mentioned here I also tried following these instructions but was not happy at the mess it was starting to leave my system in with more and more packages needing to be upgraded to testing.

will this really work out of the box on my slice (i was doing this on another server at home), is there anything less drastic i can do just to fulfill that one dependency?



Jaime Iniesta commented Fri Feb 08 13:04:52 UTC 2008:

Thanks for your articles. I've followed them and everything is working fine. I'm using nginx 0.5.35, this is the latest version now.

Timur commented Mon Oct 13 09:58:48 UTC 2008:

The right way to have more recent nginx with SSL support in Etch is getting a source package from Lenny and building it on Etch (back-porting).

This doesn't require any modifications to the source of the package itself since SSL support in nginx is already enabled in Lenny but makes the resulting binary package depend on Etch's version of libc6.

Scott Alexander commented Wed Nov 26 21:25:48 UTC 2008:

"Welcome to nginx!"

It worked! (And I'm a total n00b.)


Want to comment?

(not made public)


(use plain text or Markdown syntax)