Fix Upgrading Nginx 1.10 fails error unknown directive
Fix Upgrading Nginx 1.10 fails error unknown directive
In this short article i will show you how to solve and Fix Upgrading Nginx 1.10 fails error unknown directive.
If you ever have tried to upgrade from Nginx 1.8 to 1.10 you will realize that apt-get upgrade will blaim about unknown directive.
This is because they have implemented dynamic loading modules and moved them all into separate packages for better upgrading support, which aren’t included in the nginx.conf yet within the package upgrading process.
If you follow these steps, you will quick solve this issue.
Prerequisites:
- File Editor of your choice (vim/joe/nano e.g.) for modifying nginx.conf
- The Path of your Nginx Modules dir (I tell you later how to find it)
1. On Debian Systems, the following bash snippet gives you an ready to use output to copy/paste the output in your Nginx Config file.
for module in $(ls /usr/lib/nginx/modules/ngx_*); do echo "load_module $module;"; done
If you are running another Operating System like FreeBSD e.g. you should replace the Path: /usr/lib/nginx/modules/
to something like: /usr/local/libexec/nginx/modules/
And if you are not sure yet know the modules path for Nginx, you can check it by running: nginx -V
and watch out for the section --modules-path=
which will represent your nginx modules location.
2. Finally copy the output of the previous run of your bash snippet and paste it in the first line of your nginx.conf
This should load the dynamic modules properly now and you can try again now upgrading your packages using apt-get upgrade
(On Debian based Systems).
The upgrade process should run through without any error messages now.
If you have realized that there were some modules which you dont even use within your Nginx config sections, dont forget to just commenting them out of your nginx.conf.
That might save you some memory which you can use for other things then 😉
One final note: If you still get an Error for example this one:
invalid parameter "spdy": ngx_http_spdy_module was superseded by ngx_http_v2_module
you have to check the new parameter syntax of the module and explicit rename the parameter in our case from spdy
to http2
in your nginx config.
Make sure that SSL still function after changing that!
Updated note:
After the maintainers have changed/corrected the packaging it’s enough to extend your nginx.conf by following right after heading line pid /var/run/nginx.pid;
before starting upgrade process of nginx:
include /etc/nginx/modules-enabled/*.conf;
Cheers!