我有一個小項目,並且正在嘗試使用Django,Apache 2和mod_wsgi設置網站。在Django開發服務器中一切正常,我也可以使用apache打開我的網站的首頁。嘗試在Django管理頁面登錄時發生服務器錯誤(500)
但是,當我嘗試登錄到管理頁面或使用我自己的自定義登錄頁面時,出現服務器錯誤(500)。誰能告訴我我做錯了什麼?
settings.py:
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = ...
DEBUG = True
ALLOWED_HOSTS = ["localhost", "192.168.0.121", "127.0.0.1"]
LOGIN_REDIRECT_URL='/account'
LOGOUT_REDIRECT_URL='/login'
INSTALLED_APPS = [
'account.apps.AccountConfig',
'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 = 'kraken.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'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 = 'kraken.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
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/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
000-default.conf:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
Alias /static /home/pi/kraken/static
Alias /favicon.ico /home/pi/kraken/static/favicon.ico
<Directory /home/pi/kraken/static>
Require all granted
</Directory>
<Directory /home/pi/kraken/kraken>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess kraken python-path=/home/pi/kraken python-home=/home/pi/.conda/envs/django
WSGIProcessGroup kraken
WSGIScriptAlias//home/pi/kraken/kraken/wsgi.py
</VirtualHost>
我用CHOWN:我的數據庫www數據和我的項目文件夾
您需要查看Apache錯誤日誌中的錯誤原因。如果沒有顯示,則在Django設置文件中臨時設置「DEBUG = True」並重新啓動Web服務器。如果錯誤來自Django,則會在瀏覽器中顯示錯誤。 –
謝謝格雷厄姆,我發現什麼是錯的,看到我的答案。 – Fork2