簡體   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