Jsh*_*hee 4 django server-configuration nginx uwsgi
我有一个简单的 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
Run Code Online (Sandbox Code Playgroud)
我的站点可用/默认配置如下所示:
# 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
}
}
Run Code Online (Sandbox Code Playgroud)
我查看了nginx错误日志/var/log/nginx/error.log,发现:
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)
Run Code Online (Sandbox Code Playgroud)
我还验证了 nginxsites-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
Run Code Online (Sandbox Code Playgroud)
这里可能出了什么问题?
谢谢
您已经符号链接了目录而不是名为default.
应该有一个文件sites-enabled名为default它是一个符号链接称为文件default的sites-available目录。
尝试这个:
cd /etc/nginx/sites-enabled/
rm sites-available;
Run Code Online (Sandbox Code Playgroud)
以上应该删除导致错误的符号链接。
cd /etc/nginx/sites-enabled/
ln -s ../sites-available/default;
Run Code Online (Sandbox Code Playgroud)
上面应该创建一个名为default.
| 归档时间: |
|
| 查看次数: |
4526 次 |
| 最近记录: |