繁体   English   中英

如何在Gunicorn和Nginx(Mac OS X)上配置Django

[英]How to Configure Django on Gunicorn and Nginx (Mac OS X)

我正在尝试在Lion中使用Nginx + Gunicorn和Supervisor设置Django。 我已经安装了:

进度 :MySQL DMG + MySQLdb编译+ Python + brew nginx + easy_install gunicorn + pip安装Django + easy_install主管。

当前配置详细信息:

Nginx:
upstream app_server {
     server unix:/tmp/gunicorn.sock fail_timeout=0;
}
server {
    listen       80;
    server_name  localhost;
    #Static
    root /Users/andre/sites;
    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://app_server;
            break;
        }
    }

Gunicorn:你可以在这里看到

Supervisor:
[program:gunicorn]
command=/usr/local/bin/gunicorn main:application -c    /Users/devepy/desktop/andre/andre/gunicorn.conf.py
directory=/Users/andre/desktop/andre/myproject
user=nobody
autostart=true
autorestart=true
redirect_stderr=True

实际上我不知道该怎么办,但是花了数周的时间才尝试学习mac osx是疯狂的。

我很确定您现在一定已经解决了它,但是我遇到了一个非常不错的博客,可能会对您有所帮助。 http://cheng.logdown.com/posts/2015/01/27/deploy-django-nginx-gunicorn-on-mac-osx

我写了一个教程,介绍如何将Nginx连接到Gunicorn,将Gunicorn连接到WSGI应用程序(意味着Django,Flask,Tornado等)。

简而言之:

  • gunicorn --bind 0.0.0.0:8000 wsgi绑定到您的应用程序: gunicorn --bind 0.0.0.0:8000 wsgi
  • 更新nginx.conf以将请求传递给Gunicorn

     location / { proxy_pass http://127.0.0.1:8000; } 

如果您认为本教程中的更多详细信息将使此答案更有用,请在此处发表评论,我将在此处进行更新。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM