python - Nginx、Uwsgi、Django 问题

标签 python linux django nginx uwsgi

我正在尝试使用 nginx 和 uwsgi 运行一个 django 站点。所有配置对我来说似乎都是正确的,uwsgi 和 nginx 没有显示任何错误。但该网站仍未加载。似乎 nginx 根本没有读取 conf 文件。这里有更多的细节 项目目录:

/var/www/myproject/
/var/www/myproject/myapp
/var/www/myproject/myproject/settings.py
/var/www/myproject/myproject/wsgi.py

Nginx session :

upstream django {
 server 127.0.0.1:8001;}
server {   
listen      8181;
server_name 0.my.ip.0
charset     utf-8;
client_max_body_size 75M;
location /media  {
alias /var/www/myproject/media;
}
location /static {
    alias /var/www/myproject/static;
}
location / {
    uwsgi_pass  django;
    include     uwsgi_params;
}}

UWSGI:

[uwsgi]
chdir           = /var/www/myproject/
module          = myproject.wsgi:application
master          = true
processes       = 5
max-requests    =5000
socket          = 127.0.0.1:8001
chmod-socket    = 664
vacuum          = true
daemonize=/my/log/file.log

我是这样开始uwsgi的

sudo uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data

这是输出:

*** Starting uWSGI 2.0.11.1 (64bit) on [Sat Aug 15 12:51:58 2015] ***
compiled with version: 4.8.4 on 15 August 2015 03:50:24
os: Linux-3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015
nodename: ip-172-31-27-238
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /var/www/myproject
detected binary path: /usr/local/bin/uwsgi
setgid() to 33
setuid() to 33
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7862
your memory page size is 4096 bytes
detected max file descriptor number: 1024
*** starting uWSGI Emperor ***
*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from myproject.ini
Sat Aug 15 12:51:59 2015 - [emperor] vassal myproject.ini has been spawned
Sat Aug 15 12:51:59 2015 - [emperor] vassal myproject.ini is ready to accept         requests

我的 uwsgi conf 文件在 /etc/uwsgi/vassals 中有符号链接(symbolic link),nginx conf 在 /etc/nginx/sites-enabled 中有符号链接(symbolic link),其中有一个 default 文件提供了欢迎页面,但我也删除了它。当我打开 myip:8181 时,我可以用来调试的 nginx access.log 和 error.log 中没有显示,在浏览器中没有显示。

请查看 conf,让我知道可能是什么问题或如何调试它。

编辑: 上面的设置是正确的,问题是我尝试的端口被阻止了:(

最佳答案

确保没有防火墙阻止 8181 端口访问。

另外确保8181端口被nginx服务监听。

netstat -ntpua|grep 8181

关于python - Nginx、Uwsgi、Django 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32025335/

相关文章:

python - 可视化修改后的 SIR 模型

linux - 我想将一个脚本的输出通过管道传输到将独立处理第一个脚本的输出的不同脚本?

django - 在 django 中创建 super 用户

Django:仅更新 UpdateView 中已更改的字段

python - Pandas - 填充特定类别的平均值

python - 使用 QStackedWidget 进行多窗口 PyQt 应用程序

python - main()变量未定义

linux - Windows 10 Linux 子系统。如何安装 MongoDB

linux 邮件使用错误的域发送电子邮件

python - django - 允许用户在数据库中设置某些内容