[Fix] nginx: [emerg] “load_module” directive is specified too late in nginx.conf

Module installation for Apache si Nginx requires changes to the configuration files. nginx.conf, In our case.

For novice users, changing lines and directives in nginx.conf it can be an extreme sport, especially if I don't understand how blocks work Nginx.

The error "nginx: [emerg] “load_module” directive is specified too late in nginx.conf”Is most common when an NGINX module is added after it has been installed. Solving it is very simple and all we have to do is put the module lines at the top of the nginx.conf.

Compared to other configuration files, NGINX executes directives, definitions, and conditions in the order in which they are passed to the file. nginx.conf.

A concrete example. If we install Brotli module for NGINX, the module load lines must be immediately after the NGINX process id, so that the following specific lines take into account these modules and the process runs correctly.

 user nginx;
 worker_processes 2;
 pid /var/run/nginx.pid;
 load_module modules/ngx_http_brotli_filter_module.so;
 load_module modules/ngx_http_brotli_static_module.so;
 events {
 worker_connections 1024;
 }
 ....

After you change the location of the module loading lines, execute the command nginx -t in SSH to make sure that everything is ok and there are no other errors. Restart the NGINX service so that the changes from nginx.conf to have effect.

Passionate about technology, I enjoy writing on StealthSettings.com since 2006. I have a rich experience in operating systems: macOS, Windows, and Linux, as well as in programming languages and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, PrestaShop).

How to » Linux » [Fix] nginx: [emerg] “load_module” directive is specified too late in nginx.conf
Leave a Comment