前戏
最近在openresty上增加了weibo开源的 upsync 然后load了新增加的模块,检查配置文件的时候报错
报错信息
1 | nginx: [emerg] "load_module" directive is specified too late in /etc/nginx/nginx.conf:13 |
解决
load_module 必须在全局配置后进行配置,如下例子就是正确的:
1 | user nginx; |
就这么简单,调换个顺序,Nginx 就不会报错了。其实这样设计,也很容易理解吧,毕竟 load_module 是需要在每个 block (包括 events、http、stream、mail)之前进行加载并运行的,虽然说 /etc/nginx/nginx.conf 是声明式的配置文件,但是必须这样声明在一定程度也有利于告诉开发者其顺序的重要性吧。