nginx配置文件nginx.conf如下:user root D:\network\Video; worker_processes 4; events { worker_connections 204800; } http { include mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; keepalive_timeout 65; tcp_nodelay on; gzip on; client_header_buffer_size 4k; server { listen 8000; server_name 127.0.0.1; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-With; add_header Access-Control-Allow-Methods GET,POST,OPTIONS; location / { root D:\network\Video; autoindex on; } } } 运行nginx -p . -c ./nginx.conf时出现: [warn] "user" is not supported, ignored in ./nginx.conf:1 nginx: [emerg] CreateFile() "./mime.types" failed (2: The system cannot find the file specified) in ./nginx.conf:9如何解决
时间: 2024-02-03 18:02:22 浏览: 147
首先,关于 "user" is not supported 的警告,这是因为在 Windows 平台上,nginx 不支持指定用户,所以可以将user root这一行注释掉。
其次,关于"./mime.types" failed的错误,这是因为nginx在启动的时候找不到mime.types文件,可以在http块中添加以下内容来指定mime.types文件的路径:
```
http {
...
include mime.types;
...
}
```
指定mime.types文件的路径可以使用绝对路径或相对路径,如果使用相对路径,则相对于nginx.conf文件的路径。如果mime.types文件不存在,可以在nginx安装目录的conf目录下找到一个mime.types.default文件,将其复制一份并命名为mime.types即可。
经过以上修改后,nginx.conf文件应该如下:
```
#user root D:\network\Video;
worker_processes 4;
events {
worker_connections 204800;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
client_header_buffer_size 4k;
server {
listen 8000;
server_name 127.0.0.1;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
location / {
root D:\network\Video;
autoindex on;
}
}
}
```
阅读全文