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


0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 StumbleUpon 0 Buffer 0 Reddit 0 0 Flares ×


I am technical person. I deal with software development and services. I like to find new technologies and share new technical updates with all.

You may also like...