LoginSignup
0
1

More than 1 year has passed since last update.

djangoアプリをAWSでデプロイする時にハマったこと

Last updated at Posted at 2022-02-16

djangoアプリをAWSでデプロイする時にハマったことを個人用にメモ。

参考

https://qiita.com/Bashi50/items/d5bc47eeb9668304aaa2
https://qiita.com/Bashi50/items/db0b6b3343d51e0fc598
https://zenn.dev/ryo_t/articles/71e4ee16d76274

gunicornを起動してもソケットファイルが作成されなかった。

原因⓵:ソケットファイルを作成するフォルダに書き込み権限を付与していなかった。
原因⓶:「gunicorn.service」ファイルに誤字があった。
原因③:wsgiファイルがあるアプリフォルダ名とプロジェクトフォルダ名を違う名称にしていたため、wsgiファイルパスが間違っていた。
原因④:「Procfile」ファイルを配置していた。

Postリクエストする時に403エラーが発生する。

原因:自分のブラウザ設定でcookieをブロックしていた。

EC2インスタンスを切り替えた後に必要な作業

・djangoのsetting.pyの「ALLOWD_HOST」のIPアドレスをパブリックIPアドレスに変更。
    sudo vim /etc/nginx/sites-available/MyToDo_python
 ・nginxのIPアドレスをパブリックIPアドレスに変更。
    sudo vim /etc/nginx/sites-available/MyToDo_python
 ・nginxとgunicornサービスの再起動
    sudo systemctl restart gunicorn
    sudo systemctl restart nginx
 ・ブラウザのキャッシュクリアを行う。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1