fastcgiからgunicornへ移行したときの手順を自分用にまとめておいておく。
参考になったらいいな程度に手順をまとめる。
1.gunicornインストール
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py -U setuptools
easy_install -U gunicorn
2.nginx + gunicorn + djangoの場合
setting.pyを開いて、
INSTALLED_APPSに
"gunicorn",
を追加する。
nginxの設定ファイルを開いて、ルートドキュメントセクション内に
設定例:
location / {
#host to gunicorn server
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://127.0.0.1:8000;
break;
}
##host and port to fastcgi server
#fastcgi_pass 127.0.0.1:8080;
#fastcgi_param PATH_INFO $fastcgi_script_name;
#fastcgi_param REQUEST_METHOD $request_method;
#fastcgi_param QUERY_STRING $query_string;
#fastcgi_param CONTENT_TYPE $content_type;
#fastcgi_param CONTENT_LENGTH $content_length;
#fastcgi_pass_header Authorization;
#fastcgi_intercept_errors off;
}
python maange.py run_gunicornでまずdjangoアプリ起動
それからnginxデーモンを再起動。
http://localhost/にアクセスしてみる。
正常にページがロードされたら成功。
参照URL
http://gunicorn.org/install.html
http://gunicorn.org/run.html
0 件のコメント:
コメントを投稿