質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Gunicorn

Gunicorn (Green Unicorn)は、Rubyのunicornをベースに開発されたUNIX向けのPython製HTTPサーバです。他のライブラリとの依存関係がないため、容易にインストールして使用できます。

Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

0回答

1202閲覧

django+gunicorn+nginxにてindex.htmlを表示する際に発生するInternal Server Errorの回避

U_tanaka

総合スコア0

Gunicorn

Gunicorn (Green Unicorn)は、Rubyのunicornをベースに開発されたUNIX向けのPython製HTTPサーバです。他のライブラリとの依存関係がないため、容易にインストールして使用できます。

Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2021/09/29 08:03

編集2021/09/29 08:05

前提・実現したいこと

djangoにてホームページにhtml.indexを表示したい

ここに質問の内容を詳しく書いてください。
djangoにてindex.htmlを表示する際Internal Server Error(500)が表示されるため
この原因について教えてください。

環境
centos7.8
下記サイトを参考にしてIPアドレス/adminにログインできるところまで確認済み
https://blog.narito.ninja/detail/21/

project
├── db.sqlite3
├── manage.py
├── project
│   ├── init.py
│   ├── pycache
│   │   ├── init.cpython-36.pyc
│   │   ├── settings.cpython-36.pyc
│   │   ├── urls.cpython-36.pyc
│   │   └── wsgi.cpython-36.pyc
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── website
├── init.py
├── pycache
│   ├── init.cpython-36.pyc
│   ├── admin.cpython-36.pyc
│   ├── apps.cpython-36.pyc
│   ├── models.cpython-36.pyc
│   ├── urls.cpython-36.pyc
│   └── views.cpython-36.pyc
├── admin.py
├── apps.py
├── index.html
├── migrations
│   └── init.py
├── models.py
├── templates
├── tests.py
├── urls.py
└── views.py

発生している問題・エラーメッセージ

エラーメッセージ
Internal Server Error: /
Traceback (most recent call last):
File "/usr/local/lib64/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib64/python3.6/site-packages/django/core/handlers/base.py", line 204, in _get_response
response = response.render()
File "/usr/local/lib64/python3.6/site-packages/django/template/response.py", line 105, in render
self.content = self.rendered_content
File "/usr/local/lib64/python3.6/site-packages/django/template/response.py", line 81, in rendered_content
template = self.resolve_template(self.template_name)
File "/usr/local/lib64/python3.6/site-packages/django/template/response.py", line 63, in resolve_template
return select_template(template, using=self.using)
File "/usr/local/lib64/python3.6/site-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: index.html

該当のソースコード

#設定ファイル project/project/settings.py

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'website',
]

#設定ファイル project/project/urls.py

from django.contrib import admin
from django.urls import path,include

urlpatterns = [
path('admin/', admin.site.urls),
path('', include("website.urls")),
]

#設定ファイル project/website/views.py
from django.views.generic import TemplateView
class IndexView(TemplateView):
template_name = "index.html"

#設定ファイル project/website/urls.py
from django.urls import path
from .views import IndexView
urlpatterns = [
path('', IndexView.as_view()),
]

試したこと

コマンド
/usr/local/bin/gunicorn --workers 3 --bind 127.0.0.1:8000 project.wsgi:application

にてgnicornを立ち上げ、IPアドレス/adminにてログインできることを確認
その後ホームページに移行した際にInternal Server Error(500)が表示され
プロンプトに上記エラーメッセージが出力された

補足情報(FW/ツールのバージョンなど)

python3.6
django 3.2.7
gunicorn (version 20.1.0)
nginx-1.20.1-1

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問