django - nginx 失败成功启动错误 pread() "/etc/nginx/sites-enabled/sites-available"failed (21 : Is a directory)

标签 django nginx uwsgi server-configuration

我有一个简单的 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/ 之间建立了一个符号链接(symbolic link)。和 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

这里可能出了什么问题?

谢谢

最佳答案

您已符号链接(symbolic link)目录而不是名为 default 的文件.
sites-enabled中应该有一个文件调用default这是文件的符号链接(symbolic link) defaultsites-available目录。

试试这个:

cd /etc/nginx/sites-enabled/
rm sites-available;

以上应删除导致错误的符号链接(symbolic link)。
cd /etc/nginx/sites-enabled/
ln -s ../sites-available/default;

以上应创建一个名为 default 的符号链接(symbolic link).

关于django - nginx 失败成功启动错误 pread() "/etc/nginx/sites-enabled/sites-available"failed (21 : Is a directory),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59054255/

相关文章:

python - Flask、nginx 和 uwsgi

django - 如何使用表单对象更改提交的表单数据的值并重新显示它?

django - 带有随 secret 码的Redis AUTH

tomcat/Liferay 没有重定向到 https 主题和 Hook

node.js - 如何使用 nginx 设置 HttpOnly 响应 header ?

python - django、pyenv、uwsgi - ModuleNotFoundError : No module named 'django'

nginx - Flask + uwsgi + nginx + 调试。 502错误而不是调试器页面

python - Google App Engine 上 Django 中的包含标签

django - 获取切片后无法更新查询

nginx - http2模块nginx不工作