[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 nginx.conf.

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

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 everything is ok and there are no other errors. Restart the NGINX service for the changes in nginx.conf to take effect.


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

About the author


Passionate about everything gadget and IT, I write with pleasure on stealthsettings.com since 2006 and I like to discover with you new things about computers and operating systems macOS, Linux, Windows, iOS and Android.

Leave a Comment