当我尝试连接到django项目时出现“ 500 Internal Server Error”。
我尝试了许多方法来设置配置文件,包括一些关于stackoverflow的方法。但是我仍然无法解决问题,有人可以帮忙吗?非常感谢。
这是我的虚拟主机wsgi配置
<Directory "/home/antus/bazoo/Antus_Bazoo_Web">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess antus_bazoo python-
path=/home/antus/bazoo:/home/antus/bazoo/bazoo_env/lib/python3.7/site-
packages display-name=antus_bazoo python-home=/home/antus/bazoo/bazoo_env
WSGIProcessGroup antus_bazoo
WSGIScriptAlias / /home/antus/bazoo/Antus_Bazoo_Web/wsgi.py process-
group=antus_bazoo
这是wsgi文件
import os
import sys
import site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('/home/antus/bazoo/bazoo_env/lib/python3.7/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.append('/home/antus/bazoo')
sys.path.append('/home/antus/bazoo/Antus_Bazoo_Web')
sys.path.append('/home/antus/bazoo/antus_bazoo')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Antus_Bazoo_Web.settings")
fh = open('/home/antus/bazoo/wsgi_hello.txt', 'w')
fh.write('wsgi execution')
fh.close()
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
我也确实将错误保存在错误日志中,但是它没有任何考虑因素,甚至没有创建文件。
这是Vhost配置。
<VirtualHost *:80>
ServerName mywebsite
ServerAlias www.mywebsite
ServerAdmin webmaster@mywebsite
DocumentRoot /home/antus/public_html
UseCanonicalName Off
ScriptAlias /cgi-bin/ /home/antus/public_html/cgi-bin/
# Custom settings are loaded below this line (if any exist)
Include /usr/local/apache/conf/userdata/antus/bazoo/*.conf
ErrorLog /usr/local/apache/logs/userdata/antus/bazoo/error_log
CustomLog /usr/local/apache/logs/userdata/antus/bazoo/custom_log combined
<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled antus
</IfModule>
<IfModule mod_suexec.c>
SuexecUserGroup antus antus
</IfModule>
<IfModule mod_suphp.c>
suPHP_UserGroup antus antus
suPHP_ConfigPath /home/antus
</IfModule>
<Directory "/home/antus/public_html">
AllowOverride All
</Directory>
</VirtualHost>
答案 0 :(得分:0)
“ 500 Internal Server Error ”(500内部服务器错误)表示服务器上出现了问题,并且看到wsgi.py进行了文件打开操作,我也想从那里查找错误您提到了有关“ 未创建文件”的内容。
fh = open('/home/antus/bazoo/wsgi_hello.txt', 'w')
以上行将不会创建文件。要使用open()创建文件,请使用:
fh = open('/home/antus/bazoo/wsgi_hello.txt', 'w+')
还有一些日志可以很好地调试此