How To Compile Dynamic Modules For NGINX (HTTP Redis As An Example) - Azimut7. Drupal Web Development
How To Compile Dynamic Modules For NGINX (HTTP Redis As An Example) - Azimut7. Drupal Web Development
EN RU
Connecting additional modules to NGINX is not the most trivial thing for
web developers. Consider this task in the example build NGINX with the
https://azimut7.com/blog/dynamic-modules-nginx 1/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
Previously, to connect modules to NGINX, it was necessary to fully compile both the web
server and the required modules, but starting from version 1.9.11, you don't have to
do that. Just use the make modules command, but you need to correctly configure the
entire NGINX build.
So, first you need to know which version of NGINX is installed. If less than 1.9.11, then read
Installing the latest NGINX.
nginx -v
##
nginx version: nginx/1.13.5
Download and unpack to the home directory the same version of NGINX (in our case
1.13.5):
wget https://nginx.ru/download/nginx-1.13.5.tar.gz
https://azimut7.com/blog/dynamic-modules-nginx 2/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
wget https://people.freebsd.org/~osa/ngx_http_redis-
ngx_ 0.3.8.tar.gz
tar -xzvf ngx_http_redis-
ngx_ 0.3.8.tar.gz
Now we can compile the module and connect it in the nginx.conf file with the
command load_module my_module.so .
We need to know the current NGINX build configuration (remember result of this
command):
https://azimut7.com/blog/dynamic-modules-nginx 3/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
EN RU
nginx -V
cd nginx-1.13.5/
Preparing for the build. It takes place in two stages: "configure" and "make".
Configure
You need to run the ./configure command with the options that were shown in nginx -V .
In my case (Ubuntu 16, nginx 1.13.5) it looks like:
https://azimut7.com/blog/dynamic-modules-nginx 4/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
At the end, the path to the dynamic module is added, which needs to be compiled (we are
EN RU
in the ~/nginx-1.13.5 directory). Don't forget to add it:
--add-dynamic-module=../ngx_http_redis-
ngx_ 0.3.8
Press Enter. If you are lucky and there are no errors in the output, great!
Make
Next, make a module:
make modules
nginx-1.13.5/objs/ngx_http_redis_module.so
ngx_
To connect this module to NGINX, you need to add a line with load_module to the
/etc/nginx/nginx file.conf . To the top. Specify the full path to the file:
https://azimut7.com/blog/dynamic-modules-nginx 5/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
EN RU
sudo nano /etc/nginx/nginx.conf
Reload NGINX:
If there is no error message, then everything is worked! You can copy the
ngx_
ngx_http_redis_module.so file to a more suitable place. And do not forget to change the
path to it in nginx.conf.
NGINX update
The module is tied to a specific version of NGINX, if we update it, then most likely it will
stop working. So you need the NGINX package to put on hold — block package from
updates:
https://azimut7.com/blog/dynamic-modules-nginx 6/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
EN RU
## sudo apt-mark hold <package>
sudo apt-mark hold nginx
## Remove HOLD
# sudo apt-mark unhold <package-name>
## Check HOLD
#apt-mark showhold
«Configure» issues
1. The build configuration fails, the ./configure command returns an error (you cannot run
make modules after this).
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
https://azimut7.com/blog/dynamic-modules-nginx 7/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path>ENoption.
RU
In this example, if we change the configuration (to pass ./configure) and put --without-
http_gzip_module, most likely, at the connection stage, the module will not work with
nginx (see below).
In the process, there may be different requirements for libraries that are needed for the
NGINX build (or not).These packages may need to be installed (or may already be
installed):
2. PCRE
https://azimut7.com/blog/dynamic-modules-nginx 8/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
3. OpenSSL
https://azimut7.com/blog/dynamic-modules-nginx 9/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
6. GeoIP
EN RU
Connectivity issues
When the module was compiled but the connection to NGINX is not working:
— Module module-name.so was compiled, but when you restart NGINX, a message is
displayed that the version is not correct. In this case it's necessary to double-check and
download the appropriate version.
https://azimut7.com/blog/dynamic-modules-nginx 10/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
EN RU
nginx: [emerg] module "/usr/share/nginx/modules/ngx_http_redis_module.so"
ngx_ is not binary com
This means that the module build is configured incorrectly. You need to deal with
./configure options: incorrectly copied, not all dependencies installed and so on.
SEE ALSO
https://azimut7.com/blog/dynamic-modules-nginx 11/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
EN RU
Configure Angular 2 and Webpack Configuration forms and Ajax API in Drupal 8
https://azimut7.com/blog/dynamic-modules-nginx 12/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
Creating own event for the Rules module in Debug NGINX variables
EN
from the request
RU
Drupal 7 headers
All Posts →
Work
Blog
Contact
https://azimut7.com/blog/dynamic-modules-nginx 13/14
05-08-2023 20:33 How to compile dynamic modules for NGINX (HTTP Redis as an example) | Azimut7. Drupal web development
English Русский
EN RU
© 2023 Azimut7.
Privacy policy
https://azimut7.com/blog/dynamic-modules-nginx 14/14