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

Installation of modules for Apache and NGINX Requires changes in configuration files. nginx.conf, in our case.

For novic users, changing lines and directive in nginx.conf It can be extreme sports, especially if I don't understand how the blocks work NGINX.

error “nginx: [emerg] “load_module” directive is specified too late in nginx.conf” It is the most common when adding a nginx module after it has been installed. Its solving is very simple and we have to do nothing but put the lines of modules in the upper part of nginx.conf.

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

A concrete example. If we install The Brotti module For Nginx, the module loading lines must be immediately after the NGINX process ID, so that the following specific lines take into account these modules and the process are correctly running.

 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 have changed the place of the modules loading lines, execute the order nginx -t In SSH to make sure everything is ok and there are no other errors. Restart the NGINX service so that the changes in ninx.conf have an effect.

Passionate about technology, I write with pleasure on stealthsetts.com starting with 2006. I have a rich experience in operating systems: Macos, Windows and Linux, but also in programming languages ​​and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, Presashop).

Home Your source of IT tutorials, useful tips and news. [Fix] nginx: [emerg] “load_module” directive is specified too late in nginx.conf
Leave a Comment