nginx检查报错:nginx: [emerg] "server" directive is not allowed here in
想检查一个配置文件是否正确,-c 指定之后发现有报错,如下:
[root@op-2:~# nginx -t -c /etc/nginx/conf.d/default.conf
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/conf.d/default.conf:1
nginx: configuration file /etc/nginx/conf.d/default.conf test failed
有时候文件是正确无误,但是也会报错。
实际问题是进行语法检测的对象有问题;
要检测现有的修改过的Nginx配置是否有错误,不是只检测 .conf文件,而是不管任何时候,始终都是去检测主文件/etc/nginx/nginx.conf,只有这样,才能顺利的在对应的模块加载.conf 文件。
这样保证了配置的前后语境的正确性,这样才是真正的检测。
所以正确的检测修改的Nginx的语法是否错误的命令应该是: nginx -t -c /etc/nginx/nginx.conf ,如果配置文件有异常,会直接报出,否则就是
[root@op-2:~# nginx -t -c /etc/nginx/nginx.conf
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@op-2:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
nginx检查报错:nginx: [emerg] "server" directive is not allowed here in的更多相关文章
- 阿里云centOS7.4 nginx: [emerg] "server" directive is not allowed here in /etc/nginx/vhost/xxxxxx.conf:2
里云centOS7.4配置多个站点遇到的问题nginx: [emerg] "server" directive is not allowed here in /etc/nginx/ ...
- 重启虚拟机后,再次重启nginx会报错:[emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)
问题: 重启虚拟机后,再次重启nginx会报错: open() "/var/run/nginx/nginx.pid" failed (2: No such file or dire ...
- nginx检查报错 error while loading shared libraries: libprofiler.so.0: cannot open shared object file: No such file or directory
在centos7.3上编译安装nginx-1.12.2 启动测试出错 [root@web02 local]# /usr/local/nginx/sbin/nginx -t /usr/local/ngi ...
- nginx启动报错nginx: [error] open() "/usr/local/etc/nginx/logs/nginx.pid" failed
问题:nginx启动的时候会报丢失pid的错误 nginx: [error] open() “/usr/local/var/run/nginx.pid” failed 解决方案: sudo nginx ...
- Nginx配置SSL报错 nginx: [emerg] unknown directive "ssl"
Nginx配置SSL报错 nginx: [emerg] unknown directive "ssl" 出现如图所示错误,处理办法如下 去nginx解压目录下执行 ./co ...
- nginx启动报错
nginx启动的时候报错 nginx: [emerg] invalid number of arguments in "root" directive in /etc/nginx/ ...
- Win7下nginx默认80端口被System占用,造成nginx启动报错的解决方案
Win7下nginx默认80端口被System占用,造成nginx启动报错的解决方案 在win7 32位旗舰版下,启动1.0.8版本nginx,显示如下错误: [plain] 2012/04/0 ...
- nginx报错 nginx: [alert] kill(25903, 1) failed (3: No such process)
当nginx 中报错 时 nginx报错 nginx: [alert] kill(25903, 1) failed (3: No such process) 通过在nginx/sbin,目录下 运行命 ...
- Nginx启动报错:10013: An attempt was made to access a socket in a way forbidden
Nginx在win7,win2008下启动报错:bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket i ...
随机推荐
- 字符串连连看 (和hihocoder 字符消除类似)
题目描述 对于输入的字符串,从左到右扫描字符串,如果存在由三个以上(包括三个)连续相同字符组成的子串,就将这个子串从原串中去掉,并将原有字符串剩下的部分拼接到一起.重复上述过程,直到无法去掉任何子串 ...
- GUID在安全中作用及生成方法
参考改进于http://blog.csdn.net/jcicheng/article/details/743934 全球唯一标识符 (GUID) 是一个字母数字标识符,用于指示产品的唯一性安装.在许多 ...
- join 与 countdownlatch 的区别 扩展 栅栏 CyclicBarrier
我们先看一个 小例子 , 使用 join 与CountDownSlatch 都可以完成 当1,2线程 完全结束后 3 线程 start 对比我们就能够知道 CountDownSlatch 比 JOIN ...
- Centos 7 SSh--端口号的更改
前言:开启某服务或软件的端口,要从该服务或软件监听的端口(多以修改配置文件为主),SeLinux和防火墙(FireWall)的安全策略下手.如果使用阿里云,腾讯等第三方服务器还需要对管理控制台的安全组 ...
- vue打包后element-ui部分样式(图标)异常问题
vue项目使用element-ui组件,打包后部分样式(上下左右箭头)异常,变成方框了. 页面报warn错误,有个字体找不到. 解决办法:在build文件夹下找到utils.js,加上一行public ...
- Codeforces 975 前缀和二分算存活人数 思维离直线速度相同判平行
A /* Huyyt */ #include <bits/stdc++.h> using namespace std; typedef long long ll; ]; ]; map< ...
- Spring IOC -bean对象的生命周期详解
生命周期执行的过程如下:1) spring对bean进行实例化,默认bean是单例2) spring对bean进行依赖注入3) 如果bean实现了BeanNameAware接口,spring将bean ...
- @ResponseStatus注解作用
@ResponseStatus注解有两种用法,一种是加载自定义异常类上,一种是加在目标方法中 这里我们说一下加在目标方法上的这种情况,注解中有两个参数,value属性设置异常的状态码,reaseon是 ...
- c# 谷歌动态口令对接
https://www.cnblogs.com/easyauthor/p/11054869.html Google 身份验证器与两步验证功能配合,可在您登录 Google 帐户时为您平添一重安全保障. ...
- 电脑右键新建没有xmind文件选项解决方法
xmind还是方便的. 打开注册表,展开HKEY_CLASSES_ROOT,展开.xmind(如果没有请新建).在里面新建ShellNew项,并展开,在里面新建NullFile这个字符串值. 如果还是 ...