Nginx 报错问题汇总(持续更新ing)

目录

一、nginx: [emerg] invalid number of arguments in "include" directive in C:\Program Files\nginx-1.15.4/conf/nginx.conf:61

总结:

二、nginx: [error] OpenEvent("Global\ngx_reload_2152") failed (5: Access is denied)

解决方案:

三、nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:13

问题原因

解决办法


一、nginx: [emerg] invalid number of arguments in "include" directive in C:\Program Files\nginx-1.15.4/conf/nginx.conf:61

  1. 时间:2022-11-25
  2. 操作系统:Windows

 我是执行 nginx -s reload 时提示报错信息:

大致意思是:nginx: [emerg]在C:\Program Files\ nginx-1.15.4/conf/nginx.conf中"include"指令中的参数数量无效

根据报错信息的指示去 nginx.conf 文件的第61行代码查看:

	include C:/Program Files/nginx-1.15.4/conf/conf.d/*.conf;

我反反复复确定了单词没有拼错、路径没有写错,最后的英文分号也有。后来在网上搜索了一遍,才知道英文单词之间不能留有空格!!!(Program Files 之间有空格)

# 修改后	
include C:/ProgramFiles/nginx-1.15.4/conf/conf.d/*.conf;

再用 nginx -t 检查一遍,没有报错了:

        但是这样nginx依然检测不到这个路径,因为Windows中的 C:/Program Files 文件夹是有空格的,除非你修改这个文件夹的名字删除空格,但是这样就会影响到其他Windows上的程序,所以建议nginx还是不要安装在有空格、中文名称的目录下为好!

总结:

在nginx配置文件中填写的路径格式和目录(文件夹)名称中不能有空格、中文、反斜杠(\)!!!

二、nginx: [error] OpenEvent("Global\ngx_reload_2152") failed (5: Access is denied)

  1. 时间:2022-11-25
  2. 操作系统:Windows

使用 nginx -t 检测没有报错信息,反而使用 nginx -s reload 时出现报错:

大致报错意思是:nginx: [error] OpenEvent("Global\ngx_reload_2152") failed(5:访问被拒绝)

第一反应以为是权限问题导致的,然后用管理员权限进入cmd,依然是这个报错信息。

解决方案:

先进入nginx的安装目录,使用 start nginx.exe,再使用 nginx -s reload 即可成功!!!

三、nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:13

  1. 时间:2023-02-14
  2. 操作系统:CentOS 7.6
[root@k8s-master1 work]# nginx -t
nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:13
nginx: configuration file /etc/nginx/nginx.conf test failed

问题原因

因为在 nginx 中增加了这个 steam 模块配置:

解决办法

#1. 安装阿里云 epel.repo 源(如果第二步执行不成功,再执行这步,记得提前备份好原来的 epel.repo)
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum -y install epel-release

#2. 应该是缺少 modules 模块
yum -y install nginx-all-modules.noarch

# 然后在用 nginx -t 就好了
[root@k8s-master1 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

 

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

·哈基咩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值