How to compile and Install Nginx on Linux

0 Flares 0 Flares ×

This tutorial will describe how to compile and install Nginx on linux with different configuration options.

First of all you need the download the latest stable version of Nginx from the URL ( Then put the compressed file into the directory /usr/local/src/. Untar the file. Login as root user. Now follow the below steps:


STEP 1: cd nginx-0.8.54

STEP 2: ./configure

STEP 3: make

STEP 4: make install

By default, Nginx will be installed in /usr/local/nginx directory. /usr/local/nginx/sbin will contain the standalone Nginx application. The default installation directory can be changed with the compile time options. Below is an example of compile time options:


(This is a single line:)

./configure \

–prefix=/usr/local/myinstall \ (Defines the installation directory)
–sbin-path=/usr/local/myinstall/nginx \ (Defines the executable nginx path)
–conf-path=/usr/local/myinstall/nginx.conf \ (Defines the path to nginx conf file)
–pid-path=/usr/local/myinstall/ (Defines the path to pid file)


The above procedure installs the minimal version of Nginx i.e. it contains only the basic services and modules. If you need to use any third party modules then you need to specify the module at compile time. Below is the option to compile Nginx with 3rd party modules.

./configure –add-module=/path/to/module1/source \
By default Nginx compilation does not include SSL module. So if you want to use SSL module you need to specify it at compile time with the below option:
./configure –with-http_ssl_module.
This will enable Nginx to handle https requests.


You can always check the options available with the Nginx by using the below command:
./configure –help



+Ayodhyanath Guru holds a B.Tech degree in Electrical Engineering and has worked with various prestigious clients in the IT industry and presently working as a Software Engineer. He is a part time blogger and presently authors the Jafaloo.Com blog. Being a tech enthusiast Guru likes to surf the web and blogs about interesting technical topics like How-To guides, freewares, Tutorials, Software, Gadgets, web applications etc. Apart from blogging he likes coding in Java/J2EE and PHP.

You may also like...

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 0 Flares ×