Debian – compiling NGINX from source

Install software pre-requisites:

apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev make gcc libgeoip-dev

Get latest nginx from:

First stop nginx if it already installed then download and unpack the software:

cd /opt
tar -zxvf nginx-1.9.11.tar.gz
cd ./nginx-1.9.11
mkdir modules
cd modules
git clone
cd ..

and then there is just one more important step – to customize your server name: but in essence it all boils down to this:

Edit this file right at line #49: src/http/ngx_http_header_filter_module.c

nano -w +49 src/http/ngx_http_header_filter_module.c

Find these lines:

static char ngx_http_server_string[] = "Server: nginx" CRLF;
static char ngx_http_server_full_string[] = "Server:" NGINX_VER CRLF;

Modify those to match these new ones:

static char ngx_http_server_string[] = "Server: YourCustomName" CRLF;
static char ngx_http_server_full_string[] = "Server: YourCustomName" CRLF;

Modify “YourCustomName” as you want. You can place anything there. It could be the name of your website, product, company, etc.

Configure NGINX:

The configuration I have here works on Debian and preserves default directory layouts, provides support for IPv6, SSL, HTTPv2, WebDAV, nginx-cache-purge module and GeoIP:

./configure --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log
--pid-path=/var/run/ --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log 
--http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy 
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module 
--with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-ipv6 
--with-http_geoip_module --with-http_v2_module --add-module=$(MODULESDIR)/ngx_cache_purge

Compile and install NGINX:

make && make install

when everything is done verify:

nginx -V

and you shoud get something like that:

nginx version: nginx/1.9.11
built by gcc 4.8.2 (Debian 4.8.2-21)
TLS SNI support enabled
configure arguments: --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf 
--error-log-path=/var/log/nginx/error.log --pid-path=/var/run/ 
--lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log 
--http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy 
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module 
--with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-ipv6 
--with-http_geoip_module --with-http_v2_module

Leave a Reply

Your email address will not be published. Required fields are marked *

two × 4 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.