NGINX Webserver Starter Pack

nginx webserver linux debian ubuntu digtvbg

NGINX - got you web served

There are different webservers that exist but when we talk about linux web servers the most common ones are just two – Apache and NGINX. Apache is somehow a tad easier to use than nginx, while nginx in some scenarios can show a tad better performance. It’s a matter of personal preference which one to use. I believe nginx works better for me in my case of extremely limited server resources. Nginx can be installed in linux by either using the system package manager or by compiling from source. The package manager in Debian/Raspbian offers various nginx related packages which are named after the functionality they introduce. These could be nginx-common nginx-light nginx-full nginx-extras etc. After having the software installed then it’s a matter of configuration and a static html website is ready to be served to the public or locally. With that said, I don’t want to imply configuring nginx is the easiest task for first time installations. More on that later.

Having nginx installed directly from the distro package manager is often the recommended way but do we learn anything about the code of the program, its internals or how it is built? I doubt it. If you have some time to invest then you can try building nginx from source, I find it way funnier than the simple package manager approach. Nginx source code can be downloaded from here. Versions are in 3 categories – legacy, stable and mainline. Of course nginx source code can be obtained directly from their official source code repository which is mercurial based. This command clones the source from their repo: hg clone http://hg.nginx.org/nginx

Before compiling nginx it can be configured in some interesting and twisted ways by downloading tiny bits of source code of external plugins for nginx. They have their dedicated place online on this address. This is the moment when you decide what functionality you might need for your web based projects – should you need brotly compression, fancy directory index/listing, modsecurity waf or more headers config options just download the respective third party modules. Let’s assume we need these: headers-more-nginx-module, ModSecurity-nginx and ngx-fancyindex and we’ve downloaded all of them plus nginx source code. All the folders reside next to each other. Once we access the nginx folder (in terminal) we should know that its configure script is in the “auto” folder. So a possible correct “configure” command for nginx in our example would be something like this one:

auto/configure –with-pcre-jit –with-http_ssl_module –with-http_stub_status_module –with-http_realip_module –with-http_auth_request_module –with-http_v2_module –with-http_dav_module –with-http_slice_module –with-threads –with-http_addition_module –with-http_flv_module –with-http_geoip_module=dynamic –with-http_gunzip_module –with-http_gzip_static_module –with-http_image_filter_module=dynamic –with-http_mp4_module –with-http_perl_module=dynamic –with-http_random_index_module –with-http_secure_link_module –with-http_sub_module –with-http_xslt_module=dynamic –with-mail=dynamic –with-mail_ssl_module –with-stream=dynamic –with-stream_ssl_module –with-stream_ssl_preread_module –with-threads –with-cc-opt=”-O3 -fPIE -fstack-protector-strong -Wformat -Werror=format-security” –add-module=../ngx-fancyindex –with-file-aio –with-http_addition_module –add-module=../ModSecurity-nginx –with-compat –add-module=../headers-more-nginx-module

What a nice configure command. It can be greatly enhanced with more options and configuring various paths but I think for the sake of sanity that’s about enough.

After configure is complete then a simple make command would build nginx and then the usual “sudo make install” will install the software provided it didn’t err out while building. After that we have our custom build of nginx with some neat functionality added. If you install sql server (mariadb) and php preprocessor then you open some many more options for hosting dynamic content.

Bonus details: L E M P stack is like LAMP but with these: Linux + EnginEx (nginx) + MySQL + PHP – so basically if you combine nginx with mariadb and php you become the lemp stack guru – or at least you gain some bragging rights on the topic.

NGINX Webserver Starter Pack
Scroll to top
Left Menu Icon<- MENU