Those who use Debian and rely on nginx will sooner or later not be able to get along with the integrated modules. The solution: compile Nginx yourself.
Last updated on 09.06.2019
What sounds complicated at first, is quite simple in practice and suitable for everyday use - this blog here runs with a self compiled version Nginx 1.11.1. Although uncomplicated, there are some requirements to compile nginx under Debian 7.6 or Debian 8 (Jessie) yourself:
# apt-get install build-essential # apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
Once this is done, it's time to compile Nginx itself. First you have to download the latest version from nginx.orgthen unpack:
# mkdir nginx_temp && cd nginx_temp # wget http://nginx.org/download/nginx-1.11.1.tar.gz # tar xvfz nginx-1.11.1.tar.gz && cd nginx-1.11.1
Now the correct configuration options would have to be set so that the Debian directories would continue to be used. This is useful if you have used nginx before. So you don't have to adjust the server configuration again and can directly continue with the new nginx version.
/configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_modules --with-http_auth_request_modules --with-http_dav_modules --with-http_flv_modules --with-http_gunzip_modules ---with-http_gzip_static_modules --with-http_mp4_modules --with-http_random_index_modules --with-http_realip_modules --with-http_secure_link_modules --with-http_slice_modules --with-http_ssl_modules --with-http_stub_status_modules --with-http_sub_modules --with-http_v2_modules --with-mail --with-mail_ssl_modules --with-stream --with-stream_realip_modules --with-stream_ssl_modules --with-stream_ssl_preread_modules --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.17.0/debian/debuild-base/nginx-1.17.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' --with-openssl=/usr/local/src/openssl --add-module=/usr/local/src/nginx/incubator-pagespeed-ngx-184.108.40.206-stable --add-module=/usr/local/src/nginx/ngx_brotli
The last instructions refer to additional 3rd party modules that can be obtained from the Nginx wiki. This gives you not only a PageSpeed module, but also the possibility the Microcache to delete. If you do not use these modules, you can omit the corresponding Configure statements.
After that, all that remains is to compile and install Nginx so that the new Nginx version is available:
# make && make install
What do you get out of it? By using the current Nginx version you also get additional features that are missing from the standard Nginx. This is the only way to use the full potential of the slim web server and to take advantage of the possibilities offered by the ngx_pagespeed module.
Further information on the topic of "fast websites" can be found at Boost-for-Websites.com!
thanks for your tutorial. I have an Owncloud installation on a Raspberry and run it with NGINX and a MySQL database. My current version of NGINX is 1.2.1. Unfortunately I get an error message with the last command: make: *** No rule available to "build" the target,
required by "default". Stop.
Do you have any idea what I did wrong? I'm not very familiar with Linux... So the exact command that I have to type for compiling would help me. Greetings, Dnaiel
Did you install the Build-Essentials (the first step)? On a Raspberry Pi with Raspbian I haven't tried it yet, if there is something special to consider. But in principle the procedure should work like under x86-Linux, I will have another look at it.
Have you ever tried the latest version from the Nginx website?
My output: ./configure: error: invalid option "-with-compat".