0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

EC2+Django+nginxを本番環境にあげたときの備忘録

Last updated at Posted at 2020-01-12

最初に

ec2(linux)にdjango+nginxデプロイした時の備忘録です。
導入前は、本番環境にもかかわらず、runserver_plusを使用していました。
(個人開発的なものなので良しとしていた)
公式にもrunserverは本番環境で使うな!と書いてあります:sweat_smile:

runserver
DO NOT USE THIS SERVER IN A PRODUCTION SETTING
https://docs.djangoproject.com/ja/3.0/ref/django-admin/

導入

以下記事を参考に導入しました。
https://qiita.com/pokotsun/items/1272479e36c5146c6609

エラー確認方法と対処

以下ファイルを見る。
/var/log/nginx/error.log

エラーがある

ググっていけばOK。

エラーがない

EC2のセキュリティグループを疑ってみる。
そもそもリクエストがEC2に届いていない可能性あり。
インバウンドのHTTP,HTTPSの設定が自宅のIPになっていて接続できないことがありました。

httpで接続できるのに、httpsで接続できない!

Amazonでのセキュリティグループの設定を忘れていました。。
EC2に紐づくセキュリティグループに、TYPE"HTTPS"の設定を追加することで解消。

躓いたとこ

cssが適用されない!

https://qiita.com/xKxAxKx/items/f43d1bddbc4fb31013b1

権限がないことが原因でした。
以下で解決しました。
chmod 755 (プロジェクトまでのパス)/static/
sudo chmod o+x /home/ec2-user/で解決

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?