问题
nginx迁移过去后,新服务器上提示以下错误。
[root@nginx02 conf]# nginx -t
nginx: [emerg] unknown directive "more_set_headers" in /usr/local/nginx/conf/nginx.conf:23
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
查阅后得知,缺少header_more模块,但此模块不是nginx自带,需要另外安装。可。
解决
[root@nginx01 opt]# wget https://github.com/openresty/headers-more-nginx-module/archive/master.zip
- 解压
[root@nginx01 opt]# unzip master.zip
- 重新编译nginx,顺便添加ssl模块。不需要make install,不然会覆盖之前的安装文件,及配置。
[root@-nginx01 nginx-1.12.1]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module --add-module=/opt/headers-more-nginx-module-master
[root@nginx01 nginx-1.12.1]# make
- 编译完成后,会新生成一个nginx执行文件,在nginx-1.12.1/objs目录下,测试Ok
[root@nginx01 objs]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@kmzyw-nginx01 objs]# pwd
/usr/local/src/nginx-1.12.1/objs
- 替换之前的nginx即可
[root@nginx01 objs]# cp nginx /usr/local/nginx/sbin/nginx
cp: overwrite ‘/usr/local/nginx/sbin/nginx’? yes
[root@nginx01 objs]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
网友评论