diadia

興味があることをやってみる。自分のメモを残しておきます。

gunicornをインストールしてサービス公開

http://torajirousan.hatenadiary.jp/entry/2019/04/22/181826

collectstaticを実行

サーバーに/usr/share/nginx/html/media,/usr/share/nginx/html/staticディレクトリがあることを確認してcollectstaticを実行する。

# ディレクトリがない場合以下を実行
$ mkdir /usr/share/nginx/html/media
$ mkdir /usr/share/nginx/html/static
python3.6 manage.py collectstatic

gunicornをインストール

 

$ pip install gunicorn

manage.pyがあるディレクトリに移動する。そして以下のコマンドを入力するとサービス公開できる。

$ gunicorn --bind 127.0.0.1:8000 config.wsgi:application

 

デーモンモードで公開する。

$ gunicorn --daemon --bind 127.0.0.1:8000 config.wsgi:application



settings.py以外のファイル名で製品settings.pyを作っている場合には、当該ファイルを使用する旨をオプションとして宣言する。

$ gunicorn --daemon --env DJANGO_SETTINGS_MODULE=config.product_settings --bind 127.0.0.1:8000 config.wsgi:application