我实在太难了,我找不到配置文件第一行哪里出错了
root@NoteworthySpherical-VM:~# nginx -t
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed
原帖 https://blog.csdn.net/lpwmm/article/details/116943643
- server {
listen 80;
server_name localhost;
# 设置使用utf-8编码,防止中文文件名乱码
charset utf-8;
# 默认存放文件的路径
root /home/dav;
auth_basic realm_name;
# 用户密码文件存放位置
auth_basic_user_file /etc/nginx/.passwords.list;
# dav 允许的操作
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
# 创建文件的默认权限
dav_access user:rw group:rw all:r;
# 临时文件位置
client_body_temp_path /tmp;
# 最大上传文件限制, 0表示无限制
client_max_body_size 0;
# 允许自动创建文件夹(如果有需要的话)
create_full_put_path on;
}
热议
2楼 Liu`e 3小时前
检查include的配置文件吧
3楼 似毛非毛 3小时前
配置内容放错地方了吧?猜的。
4楼 nebulabox 3小时前
只有 http { } 或者 stream {} 里面才能有server
6楼 Waylon 3小时前
人家为了省事只写了server那一段。
7楼 天蓝星空 3小时前
楼上都是正解
8楼 YorkZhao 3小时前
我直接caddy
9楼 j6hokqgfrr 1小时前
检查include的配置文件吧
没有
就上面的直接放到配置文件里
10楼 j6hokqgfrr 1小时前
配置内容放错地方了吧?猜的。
嗯
貌似是的
得慢慢去摸索
12楼 j6hokqgfrr 1小时前
人家为了省事只写了server那一段。
嗯
以为就server那一段
就可以了 还得匹配哦
麻烦
13楼 j6hokqgfrr 1小时前
location / {
root /home/dav;
indexindex.html index.htm;
auth_basic realm_name;
auth_basic_user_file /etc/nginx/.passwords.list;
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
dav_access user:rw group:rw all:r;
client_body_temp_path /tmp;
client_max_body_size 0;
create_full_put_path on;
}
nginx -t
提示这一行出错
dav_ext_methods PROPFIND OPTIONS;
去掉提示 500 Internal Server Error
14楼 aru 1小时前
location / {
root /home/dav;
indexindex.html index.htm;
你那个配置是网站的配置,nginx 要最基础的http配置!
给你一个最简单的配置
worker_processes4;
http {
access_log/var/log/nginx/access.log;
include /etc/nginx/conf.d/*.conf;
}
将上面的这个配置作为nginx.conf 配置,然后将你原来的配置保存为 /etc/nginx/conf.d/web1.conf
多个网站就多份配置放在 /etc/nginx/conf.d 里面
申明:本文内容由网友收集分享,仅供学习参考使用。如文中内容侵犯到您的利益,请在文章下方留言,本站会第一时间进行处理。
谷姐靓号网



评论前必须登录!
立即登录 注册