嘿嘿!报错不断呀!快哉快哉,检测nginx配置文件时报错,整它!

1.报错具体信息

nginx: [emerg] invalid number of arguments in “location” directive in /usr/local/nginx/conf/nginx.conf:47
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

2.报错背景

在完成源码安装LNMP架构完成的情况下,对nginx服务进行优化,在设置缓存时间的配置时。修改过配置文件后,检测配置文件时报错。
具体报错信息如下:

[root@localhost html]# vim /usr/local/nginx/conf/nginx.conf

[root@localhost html]# nginx -t
nginx: [emerg] invalid number of arguments in "location" directive in /usr/local
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
[root@localhost html]# vim /usr/local/nginx/conf/nginx.conf

3.排错分析过程

这个问题比较简单,看报错信息可以判断,问题出在配置文件的47行,应该就是配置时有错误,进入配置文件查看47行内容并且查错。

[root@localhost html]# vim /usr/local/nginx/conf/nginx.conf

在这里插入图片描述
可以发现47行配置的是识别图片的格式,以多个格式结尾的图片,格式和$要连起来不能有空格,才表示以什么结尾。所以有空格是错误的。

4.解决方法

去掉配置文件中多余的空格应该就可以解决了。

在这里插入图片描述

5.验证

[root@localhost html]# 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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值