阿里云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/vhost/xxxxxx.conf:2
这个错误好尴尬,
费了几个小时去解决,小白呀没办法
先贴下/etc/nginx/nginx.conf的内容
worker_processes 1;
events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65; include /etc/nginx/vhost/*.conf; server {
listen 80;
server_name _;
root /usr/share/nginx/html;
include /etc/nginx/vhost/*.conf;
}
}
vhost/mayifa.conf内容
server
{
listen 80;
server_name localhost;
root /data/www/mayifanx;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
就这个配置好好的,systemctl restart nginx ,依照命令使用systemctl status nginx.service
检测为什么为老是报错
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/vhost/xxxxxx.conf:2

所以nginx.conf中server节点的 include /etc/nginx/vhost/*.conf; 应该被删掉
正确的/etc/nginx/nginx.conf配置如下
worker_processes 1;
events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65; include /etc/nginx/vhost/*.conf; server {
listen 80;
server_name _;
root /usr/share/nginx/html;
}
}
systemctl restart nginx
终于正常了。
可以使用 nginx -t -c /etc/nginx/nginx.conf 这个检测配置是否正常,今天才明白nginx.conf配置是把你指定include配置一起包含的,类似C++中的include
阿里云centOS7.4 nginx: [emerg] "server" directive is not allowed here in /etc/nginx/vhost/xxxxxx.conf:2的更多相关文章
- nginx检查报错:nginx: [emerg] "server" directive is not allowed here in
想检查一个配置文件是否正确,-c 指定之后发现有报错,如下: [root@op-2:~# nginx -t -c /etc/nginx/conf.d/default.conf nginx: [emer ...
- nginx: [emerg] unknown directive "聽" in D:\software03\GitSpace\cms\nginx-1.14.0/conf/nginx.conf:36
nginx: [emerg] unknown directive "聽" in D:\software03\GitSpace\cms\nginx-1.14.0/conf/nginx ...
- nginx: [emerg] "proxy_cache_path" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:43
1.它只能使用于http{ }部分,把proxy_cache_path放置于http部分即可解决此问题.注意图示的上下文
- 阿里云centos7服务器nginx配置及常见问题解答
前言: 本文参考了jackyzm的博客:https://www.cnblogs.com/jackyzm/p/9600738.html,进行了内容的更新,并请注意这里适用的版本是centos7的版本.并 ...
- 配置 nginx server 出现nginx: [emerg] "root" directive is duplicate in /etc/nginx/server/blogs.conf:7
在配置nginx 虚拟机时,执行 sudo /usr/sbin/nginx -t 报下面的错误: nginx: [emerg] nginx: configuration file /etc/nginx ...
- 阿里云centos7搭建php+nginx环境
阿里云Centos搭建lnmp(php7.1+nginx+mysql5.7) https://jingyan.baidu.com/article/215817f7a10bfb1eda14238b.ht ...
- 阿里云CentOS7.3服务器通过Docker安装Nginx
前言 小编环境: 阿里云CentOS7.3服务器 docker 下面分享一次小编在自己的阿里云CentOS7.3服务器上使用Docker来安装Nginx的一次全过程 温馨小提示: 如果只是希望单纯使用 ...
- 阿里云centos7成功安装和启动nginx,但是外网访问不了的解决方案
问题环境: 阿里云centos7.4.1708 问题描述:成功配置,启动成功,外网访问不了 解决方案: 经过查阅文档,去阿里云后台查看,原来是新购的服务器都加入和实例安全组. (OMG)立即去配置.加 ...
- 阿里云CentOS7部署ASP.NET Core
本文主要介绍了阿里云CentOS7下如何成功的发布ASP.Core应用并使用nginx进行代理, 并对所踩的坑加以记录; 环境.工具.准备工作 服务器:阿里云64位CentOS 7.4.1708版本; ...
随机推荐
- JDK源码分析之concurrent包(二) -- 线程池ThreadPoolExecutor
上一篇我们简单描述了Executor框架的结构,本篇正式开始并发包中部分源码的解读. 我们知道,目前主流的商用虚拟机在线程的实现上可能会有所差别.但不管如何实现,在开启和关闭线程时一定会耗费很多CPU ...
- 第三课作业——set类型、sorted set类型的增删改查,redis的事务
第三课时作业 静哥 by 2016.2.23~2016.3.6 [作业描述] 1.总结什么是set以及什么是sorted set,并完成对set以及sorted set的增删改查(查需要至少4种方 ...
- c#读取excel到dataset
public DataSet TransExcelToDataSet(string fileName, List<string> sheetNames) { OleDbConnection ...
- 关于vtt 与 srt 字幕 的相互转换
我在下载的udacity中教程时,字幕和视频是分离的,对于英文还无法完全听懂的我来说,字幕还是比较重要.不想看解释的可直接跳到最后复制代码运行即可. 查看了vtt和srt的区别,使用记事本打开vtt和 ...
- IDEA 录制宏+设置快捷键 实现写时编译
参考: IDEA 录制宏+设置快捷键 实现写时编译:https://blog.csdn.net/wangjie919/article/details/79487981 IDEA 设置运行时不编译项目: ...
- Ionic的下拉框在手机上点击无效
最近在维护ionic+angular的项目,在浏览器使用下拉框的时候调试的时候,一切正常. 但是在手机上测试的时候,遇到这个问题. 我使用的版本是ionic1.3.1,不知道新版本有没有解决这个bug ...
- 携程greenlet模块使用
import greenlet def f1(): print(11) gr2.switch() print(22) gr2.switch() def f2(): print(33) gr1.swit ...
- Linux下套接字具体解释(九)---poll模式下的IO多路复用server
參照 poll调用深入解析-从poll的实现来讲poll多路复用模型,非常有深度 poll多路复用 poll的机制与select相似,与select在本质上没有多大差别.管理多个描写叙述符也是进行轮询 ...
- 用python合并N个不同字符集编码的sql文件的实践
背景:我有一项工作任务是将svn某文件夹日常更新的sql文件(归类到日期命名的文件夹中)拿到数据库中运行. 一開始,我是先把sql文件update下来,用notepad++打开,拷贝每个文本的sql语 ...
- bzoj1101【POI007】Zap
1101: [POI2007]Zap Time Limit: 10 Sec Memory Limit: 162 MB Submit: 1950 Solved: 735 [id=1101" ...