nginx 失败成功启动错误 pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directo
Posted
技术标签:
【中文标题】nginx 失败成功启动错误 pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)【英文标题】:nginx fails successfully start with error pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory) 【发布时间】:2020-03-22 01:38:28 【问题描述】:我有一个简单的 django 网站,我正在尝试使用 nginx 和 uwsgi 加载。
当我尝试测试我的 nginx 配置时,我得到以下信息:
$ sudo nginx -t
nginx: [crit] pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
我的站点可用/默认配置如下:
# the upstream component nginx needs to connect to
upstream django
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
# configuration of the server
server
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name website.com xx.xx.x.x; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 2M; # adjust to taste
# Django media
#location /media
# alias ; # your Django project's media files - amend as required
#
location /static
alias /static; # your Django project's static files - amend as required
# Finally, send all non-media requests to the Django server.
location /
uwsgi_pass 127.0.0.1:8001;
include uwsgi_params; # the uwsgi_params file you installed
我在/var/log/nginx/error.log
查看了nginx错误日志,发现:
2019/11/26 14:29:53 [crit] 7702#7702: pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)
2019/11/26 15:05:25 [crit] 7736#7736: pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)
我还验证了在 nginx 的 sites-available/
和 sites-enabled
之间建立了符号链接:
$ sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
ln: failed to create symbolic link '/etc/nginx/sites-enabled/sites-available': File exists
这里可能出了什么问题?
谢谢
【问题讨论】:
【参考方案1】:您已符号链接目录而不是名为 default
的文件。
sites-enabled
中应该有一个名为default
的文件,它是sites-available
目录中名为default
的文件的符号链接。
试试这个:
cd /etc/nginx/sites-enabled/
rm sites-available;
以上内容应删除导致错误的符号链接。
cd /etc/nginx/sites-enabled/
ln -s ../sites-available/default;
上面应该创建一个名为default
的符号链接。
【讨论】:
完成此操作后,启动 nginx,然后启动 uwsgi 我收到 HTTP 502 错误“上游过早关闭连接,同时从上游读取响应标头”??以上是关于nginx 失败成功启动错误 pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directo的主要内容,如果未能解决你的问题,请参考以下文章
docker 启动失败 Job for docker.service failed because the control process exited with error code. See &q