Обслуживание приложения Django с помощью Apache 2 на виртуальном хосте

Я изучаю фреймворк Django и могу запустить свое первое приложение на сервере разработки, используя:

python3 manage.py runserver

enter image description here

Однако на самом деле я хочу обслуживать свое приложение с помощью Apache, чтобы к нему можно было получить доступ из Интернета. Мой виртуальный хост Apache следующий:

<VirtualHost *:443>
    ServerName django.example.com
    DocumentRoot /var/www/django/hello_world/mysite
    WSGIScriptAlias / /var/www/django/hello_world/mysite/mysite/wsgi.py

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLEngine On
    SSLCertificateFile /etc/letsencrypt/live/django.example.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/django.example.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/django.example.com/chain.pem

    WSGIDaemonProcess django.sample.com processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/django/hello_world/mysite/venv/lib/python3.6
    WSGIProcessGroup django.sample.com

    <directory /var/www/django/hello_world/mysite>
        AllowOverride all
        Require all granted
        Options FollowSymlinks
    </directory>
</VirtualHost>

Как вы можете видеть, это не сложное приложение, которое я пытаюсь запустить, просто стартовая страница Django по умолчанию, но я получаю:

enter image description here

Мой файл settings.py имеет следующий вид:

from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent

SECRET_KEY = 'django-insecure-3b^iz&pognt=yt5m&(!w@keo&*@a9zb&)$n@32v!yj4w%c!k-4'

DEBUG = True

ALLOWED_HOSTS = [ 'django.sample.com' ]

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

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'mysite.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'mysite.wsgi.application'

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

Я использую Apache 2.4.6, CentOS 7. Спасибо за любую помощь.

Вернуться на верх