nginx - 如何解决 Nginx 错误 nginx: [emerg] conf:1 中的未知指令“server”?
问题描述
我改了nginx的配置,然后在出现如下错误的时候重启了nginx。
[root@host ~]# nginx -s reload
nginx: [emerg] unknown directive "server" in /usr/local/openresty/nginx/conf/vhost/www.xxx.com.conf:1
这是我的配置。我该如何解决这个问题?
server {
server_name www.xxx.com xxx.com;
listen 80;
listen 443;
ssl on;
ssl_certificate /data/https/domain.pem;
ssl_certificate_key /data/https/domain.key;
root /data/wwwroot/www.xxx.com;
index index.html index.htm index.php;
#rewrite
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
location ~ {
proxy_pass http://127.0.0.1:8080;
include proxy.conf;
}
location /nginx_status {
stub_status on;
access_log off;
#allow 127.0.0.1;
# deny all;
}
location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip: 9000;
#fastcgi_pass 127.0.0.1: 9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location ~ /\.ht {
deny all;
}
access_log off;
}
接下来我用了-t检验,结果是这样的。
[root@host ~]# nginx -t
nginx: [emerg] unknown directive "server" in /usr/local/openresty/nginx/conf/vhost/www.xxx.com.conf:1
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test failed
我刚刚添加了反向代理代码并将其上传到服务器。这部分代码删不掉,不知道怎么解决。
解决方案
发现问题,是windows记事本用BOM格式保存的,用vscode重新选择no bom格式UTF-8。
推荐阅读
- c++ - 什么 Cpp 编译器允许内联汇编代码?
- django - 如何根据用户状态过滤列表视图查询集
- node.js - NodeJs sequelize 获取数据之间的日期
- c - 为什么在将节点插入头部(链表)时使用双指针?
- python - 使用python将图像(使用json)排序到文件夹
- node.js - User.destroy 不是函数
- powershell - 如何使用 PowerShell 执行 CMD 文件以自动设置环境变量?
- php - 如何根据另外两个表的计算从一个表中检索数据?
- r - R:进度条不从 0 开始
- javascript - Raycaster 在窗口的第二个场景中没有找到相交