微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Django + Gunicorn + nginx内部服务器错误,错误在哪里以及如何解决?

所以我正在运行非常标准的设置,我跟着我以前做过的相同的教程,但现在不知道原因不起​​作用。

当我运行./manage.py runserver my_ip:8000它工作正常。 当我通过bin/gunicorn_start运行我的gunicorn脚本,它工作正常,并创build了袜子文件然而,当我通过监督和Nginx运行gunicorn脚本,它导致与Internal Server Error ,并没有错误日志中的信息。 我究竟做错了什么? 我猜这是gunicorn或权限问题?

斌/ gunicorn_start

#!/bin/bash NAME="today" # Name of the application DJANGODIR=~/deployment/today_project/ SOCKFILE=~/deployment/run/gunicorn.sock # we will communicte using this unix socket USER=ferski # the user to run as GROUP=ferski # the group to run as NUM_WORKERS=3 # how many worker processes should Gunicorn spawn DJANGO_SETTINGS_MODULE=today_project.settings # which settings file should Django use DJANGO_Wsgi_MODULE=today_project.wsgi # Wsgi module name echo "Starting $NAME as `whoami`" # Activate the virtual environment cd $DJANGODIR source ../bin/activate export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE export PYTHONPATH=$DJANGODIR:$PYTHONPATH # Create the run directory if it doesn't exist RUNDIR=$(dirname $SOCKFILE) test -d $RUNDIR || mkdir -p $RUNDIR # Start your Django Unicorn # Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon) exec ../bin/gunicorn ${DJANGO_Wsgi_MODULE}:application --name $NAME --workers $NUM_WORKERS --user=$USER --group=$GROUP --log-level=debug --bind=unix:$SOCKFILE

/etc/supervisord.conf(只是未知的文件

[unix_http_server] file=/tmp/supervisor.sock ; (the path to the socket file) ... [supervisorctl] serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket ... [program:today] command = /home/ferski/deployment/bin/gunicorn_start user = ferski stdout_logfile = /home/ferski/deployment/logs/gunicorn_supervisor.log redirect_stderr = true ...

最后是Nginx.conf

upstream today_app_server { server unix:/home/ferski/deployment/run/gunicorn.sock fail_timeout=0; } server { listen 80; server_name haxelita.pl; client_max_body_size 4G; access_log /home/ferski/deployment/logs/Nginx-access.log; error_log /home/ferski/deployment/logs/Nginx-error.log; location /static/ { alias /home/ferski/deployment/today_project/today/static/; } location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://today_app_server; break; } } # Error pages error_page 500 502 503 504 /500.html; location = /500.html { root /home/ferski/deployment/today_project/today/static/; } }

这里怎么了? 这是权限问题吗?

Django在apache2上的MysqLdb问题

Nginx.service:无法从文件/run/Nginx.pid中读取PID:无效的参数

在Django中,如何让打印语句与Apache Wsgi一起工作?

在Django的debugging和生产中configuration静态文件的最常见方法是什么?

是Django最好的解决scheme,如果有的话,请帮助我

在Windows 7上将“django-admin.py”path添加到命令行

在Windows上,virtualenv没有被用于我运行一个python程序

Django说所有图片都是无效的,但是PIL工作

Django + uwsgi + Nginxredirect到页面“欢迎使用Nginx

带有别名的Nginx浏览器caching

您无法通过source在启动监控程序的脚本中激活virtualenv环境。 在你的supervisord.conf中使用directory=/home/ferski/deployment/today_project/ 。

请参阅通过主管监督virtualenv django应用程序

这个问题困扰了我。 但是我想通了,我想我会张贴它的未来参考,因为这是谷歌搜索这个错误的顶部。

uwsgi --socket /path/to/sock --chdir /path/to/django/project/ --module project_name.wsgi --chmod-socket=664

然后你可以添加内核和处理器的数量,但是附加这个(把你的应用程序的内核数量改为4)。

--master --processes 4 --async 4 --ugreen

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐