Django在HTTPS上显示500 Internal Server Error

时间:2019-12-17 20:22:12

标签: django ssl https apache2 mod-wsgi

我在apache2目录的error.log中遇到以下错误:Segmentation fault (11), possible coredump in /etc/apache2

我的example-instance.conf中具有以下配置:

 ErrorDocument 404 "/error-pages/404.html"
 ErrorDocument 500 "/error-pages/500.html"
 ErrorDocument 403 "/error-pages/403.html"

 # Change the following three lines for your server

 ServerName example.app
 SetEnv HTTP_HOST "example.app"
 ServerAdmin admin@example.app

 SetEnv LC_TIME "en_GB.UTF-8"
 SetEnv LANG "en_US.UTF-8"

 SSLEngine on

 SSLCertificateFile "path/to/certificate"
 SSLCertificateChainFile "path/to/certificate"
 SSLCertificateKeyFile "path/to/private_key"

 WSGIScriptAlias /app "path/to/wsgi_prod.py"

 # Comment next 2 lines if using older Apache than v2.4
 WSGIApplicationGroup %{GLOBAL}
 WSGIDaemonProcess instance1_wsgi python-path="__PATH_TO_ENV_SITE-PACKAGES_FOLDER__"
 WSGIProcessGroup instance1_wsgi

 # Comment 'Require all granted' for older Apache than v2.4

 <Location "/">
   Require all granted
   Options FollowSymLinks
 </Location>

 Alias /static/ "path/to/static/"
 Alias /app/static/ "path/to/static/"
 <Directory "path/to/static/">
   Require all granted
   Options -Indexes
 </Directory>

 Alias /data/ "path/to/data/"
 <Directory "path/to/data/">
   Require all granted
   Options -Indexes
 </Directory>

 ErrorLog ${APACHE_LOG_DIR}/example-instance-error.log
 LogLevel warn
 CustomLog ${APACHE_LOG_DIR}/example-instance-access.log combined

该站点在http上运行良好,但是在为https配置该站点时,我在Django应用所在的'/ app'子目录中获得了500 Internal Server Error。该网站的目标网页非常好,表明https正常运行。

2 个答案:

答案 0 :(得分:0)

我也遇到同样的问题://目前唯一的选择是关闭mod_ssl并返回配置文件中的端口80。

奇怪的是,我在settings.py中具有Debug = True,但是当应用崩溃时,我从apache只收到错误500页面。

答案 1 :(得分:0)

结果证明pip install psycopg2-binary确实成功了!