Build nginx from source

I use nginx as a webserver for my websites. When installed from aptitude, it comes with a lot of modules that I do not need, so I made a customized version of nginx, to make nginx the way I want it.

First, you have to download the latest version of nginx from the website. Version 1.7.10 is the latest version at this moment.

wget http://nginx.org/download/nginx-1.7.10.tar.gz

Then, you have to extract the files from the tar-archive

tar xzf nginx-1.7.10.tar.gz

Then, browse into the folder in which the files are extracted

cd nginx-1.7.10/

Execute the configure script

./configure \
--user=www-data \
--group=www-data \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--http-log-path=/var/log/nginx/access.log \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-scgi-temp-path=/var/lib/nginx/scgi \
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
--lock-path=/var/lock/nginx.lock \
--pid-path=/var/run/nginx.pid \
--with-http_realip_module \
--with-ipv6 \
--with-cpu-opt=amd64 \
--with-http_ssl_module \
--with-http_spdy_module \
--without-select_module \
--without-http_browser_module \
--without-http_empty_gif_module \
--without-http_geo_module \
--without-http_map_module \
--without-http_limit_req_module \
--without-http_limit_conn_module \
--without-http_memcached_module \
--without-http_scgi_module \
--without-http_split_clients_module \
--without-http_ssi_module \
--without-http_userid_module \
--without-http_uwsgi_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--with-cc-opt=-O3

Then, stop nginx, make and install the custom compiled version of nginx, and start it.

service nginx stop && make && make install && service nginx start

To make sure it’s the new version, check the version number of the running version:

nginx -v