小编使用宝塔面板安装编译Nginx 1.22.0,再安装Nginx免费防火墙 6.6版本运行出错!
重启nginx错误提示:
Nginx配置规则错误:
nginx: the configuration file /www/server/nginx/conf/nginx.conf syntax is ok或
Nginx配置规则错误:
nginx: the configuration file /www/server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /www/server/nginx/conf/nginx.conf test failed
解决方案:
第一步、打开nginx-配置修改-把第三行的error_log /www/wwwlogs/nginx_error.log crit;修改为
error_log /www/wwwlogs/nginx_error.log debug; //记得成功后再改回来。
第二步、去SSH里面运行nginx -t 看看报什么错误。
比如我的这个是报这个错误:
[root@cx ~]# nginx -t
nginx: the configuration file /www/server/nginx/conf/nginx.conf syntax is ok
nginx: [error] init_by_lua_file error: error loading module 'cjson' from file '/usr/local/lib/lua/5.1/cjson.so':
/usr/local/lib/lua/5.1/cjson.so: undefined symbol: luaL_setfuncs
stack traceback:
[C]: at 0x7f038af72b80
[C]: in function 'require'
/www/server/free_waf/init.lua:8: in main chunk
nginx: configuration file /www/server/nginx/conf/nginx.conf test failed
[root@cx ~]#
对比别的相同配置系统检查了下/usr/local/lib/lua/5.1,发现此文件夹缺少文件,补好缺漏文件即可,再重新启动nginx成功。
(所需文件在右侧下载,上传解压到相应目录!)
记得成功后看第一步,把之前修改数值改回来即可,再起重启下!
或者把下面的,注释掉也行!