ウェブへのデプロイ

tera termのインストール

tera termをインストールします。 以下のサイトからダウンロードしてインストールしてください。 https://ja.osdn.net/projects/ttssh2/releases/

winscpのインストール

winscpをインストールします 以下のサイトからダウンロードしてインストールしてください。

https://forest.watch.impress.co.jp/library/software/winscp/

データベースの準備

powershellを起動します モンスター効果クリック

power shellから

mysqldump -u username -p -h localhost tcgcreator > test.sql

と入力します

conohaのサーバーの準備

conohaのユーザー登録等はご自分でなさってください

モンスター効果クリック

管理画面でサーバーを選択します モンスター効果クリック プランはチュートリアルなので一番安いプランをお勧めします。ubuntu20.04を選択します

モンスター効果クリック サーバー管理画面から詳細情報を入力します。

モンスター効果クリック ipアドレスをメモります

winscpの設定

新しいサイトをclickして、host名に先ほどメモったipアドレスuserにroot パスワードはさきほどconohaに入力してものを入力します。 モンスター効果クリック

モンスター効果クリック winscpにてtcg_creator_instal.sh,mysiteをコピーします

tera termで

bash ./tcgcreator_tutorial

と入力します モンスター効果クリック

mysql -uusername -ppassword tcgcreator < tcgcreator.sql

winscpで /etc/systemd/systemに移動します モンスター効果クリック gunicorn.serviceをアップロードします モンスター効果クリック

winscpで /etc/nginx/sites-availableに移動します モンスター効果クリック mysite.txtをアップします

/root/mysite/mysiteに移動しsettings.pyのallowed_hostsに先ほどメモったipaddressを入力牛ます モンスター効果クリック ALLOWED_HOSTSに先ほどメモったIPアドレスを入力します モンスター効果クリック ALLOWED_HOSTS = [...]

ここからはtera termです。 tera termにIPアドレスをさっきメモったipaddressパスワードに先ほど入力したパスワードを入力します。 モンスター効果クリック モンスター効果クリック

以下のコマンドを入力します

sudo ln -s /etc/nginx/sites-available/mysite.txt /etc/nginx/sites-enabled/

sudo ufw delete allow 8000

sudo ufw allow ‘Nginx Full’

ce mysite

python3 manage.py collectstatic

sudo systemctl restart gunicorn

sudo systemctl restart nginx

以上で基本的なデプロイは終了です。 サイトのアドレスや、HTTPS化は以下のサイトを参考にしてください。

https://tomato-develop.com/django-ubuntu-python-nginx-gunicorn-postgresql/