阿里云centOS7.4 nginx: [emerg] "server" directive is not allowed here in /etc/nginx/vhost/xxxxxx.conf:2
2024-08-28 23:47:49
里云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
最新文章
- Aircrack-ng: (2) WEP &; WPA/WPA2 破解
- h5自定义audio(问题及解决)
- 工厂方法模式与IoC/DI
- Win 2003硬盘安全设置
- Location 对象
- CAT XQX --- 省市三级级联实现说明
- Objective-c开发中混合使用ARC
- uestc 250 数位dp(水)
- 有人实践过 Phabricator 以及 Arcanist 作为 code review 的工具么?(转)
- [js高手之路]面向对象+设计模式+继承一步步改造简单的四则运算
- 系统调用syscall---用户态切换到内核态的唯一途径
- Android Thread 官方说明
- 解决find命令报错: paths must precede expression
- Gitlab--安装及汉化
- 在MyEclipse中使用javadocAPI文档
- hibernate ORA-17059 无法转换为内部表示
- 《Python程序设计(第3版)》[美] 约翰·策勒(John Zelle) 第 3 章 答案
- 代码生成器 CodeSmith 的使用(五)
- python中range()、list()函数的用法
- 简易配置Django的Static文件
热门文章
- instanceof和isInstance(Object obj) 和isAssignableFrom(Class cls)的区别和联系
- ios 画图总结
- Linux基础命令(四)
- Compilation failed: internal java compiler error
- 解决: ./netapp.bin: error while loading shared libraries: libcaffe.so.1.0.0: cannot open shared object file: No such file or directory 运行时报错(caffe)
- java容器的线程安全性
- 解决ajax post json数据 后端无法收到的问题
- MySQL给字段唯一索引的三种方法
- struts 文件下载 annotation 注解版
- 利用python的turtle重复画六边形