缺少“mime.types”文件导致 nginx 失败

缺少“mime.types”文件导致 nginx 失败

我在 Arch Linux 上并安装了nginx-mainline.我在运行时遇到错误sudo systemctl start。这是输出sudo systemctl status nginx.service

     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Sat 2020-08-22 21:04:55 EDT; 8s ago
    Process: 2660 ExecStart=/usr/bin/nginx -g pid /run/nginx.pid; error_log stderr; (code=exited, status=1/FAILURE)

Aug 22 21:04:55 archlinux.homelab.local systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 22 21:04:55 archlinux.homelab.local nginx[2660]: 2020/08/22 21:04:55 [emerg] 2660#2660: open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:18
Aug 22 21:04:55 archlinux.homelab.local systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Aug 22 21:04:55 archlinux.homelab.local systemd[1]: nginx.service: Failed with result 'exit-code'.
Aug 22 21:04:55 archlinux.homelab.local systemd[1]: Failed to start A high performance web server and a reverse proxy server.

我的/etc/nginx/nginx.conf文件包括这个:

http {
    include       mime.types;
    # Bunch of other code I've excluded for simplicity
}

确实如此, 中没有mime.types文件/etc/nginx/。我如何开始nginx工作?

答案1

我不知道 arch-linux,但通常包应该包含该文件。

但是,您始终可以从上游获得替代品:-)

https://raw.githubusercontent.com/nginx/nginx/master/conf/mime.types

其中包含当前的主mime.types文件。

您只需下载该文件并将其放入配置目录中即可。

相关内容