【问题标题】:500 Internal Server Error django + mod_wsgi + apache2 on ubuntu 16ubuntu 16 上的 500 内部服务器错误 django + mod_wsgi + apache2
【发布时间】:2019-11-25 08:42:52
【问题描述】:

我正在尝试在 Ubuntu 服务器上部署我的应用程序,据我所知,我所做的一切都是正确的,但我总是收到 500 内部服务器问题错误。

我尝试了很多故障排除指南,但找不到任何有用的东西可以解决问题。 这是 /etc/apache2/sites-available 配置文件

        Alias /static /home/local/user/wesupportapp/static
        <Directory /home/local/user/wesupportapp/static>
                Require all granted
        </Directory>

        Alias /media /home/local/user/wesupportapp/media
        <Directory /home/local/user/wesupportapp/media>
                Require all granted
        </Directory>

         <Directory /home/local/user/wesupportapp/wesupportapp>

        <Files wsgi.py>
        Require all granted
        </Files>
  </Directory>

  WSGIScriptAlias / /home/local/user/wesupportapp/wesupportapp/wsgi.py
  WSGIDaemonProcess django_app python-path=/home/local/user/wesupportapp python-home=/home/local/user/wesupportapp/venv
  WSGIProcessGroup django_app

当我在 django 的开发服务器上运行应用程序时,一切正常,但是一旦我启用应用程序 conf 文件,我就会出现 500 错误。

如果有人遇到与我相同的问题并能真正帮助我解决这个问题,我们将不胜感激。

apache2 错误日志

[Tue Jul 16 10:42:33.386640 2019] [wsgi:error] [pid 6299:tid 139834262898432] [remote 10.72.15.5:3756]   File "/home/local/user/wesupportapp/wesupportapp/wsgi.py", line 12, in <module>
[Tue Jul 16 10:42:33.386644 2019] [wsgi:error] [pid 6299:tid 139834262898432] [remote 10.72.15.5:3756]     from django.core.wsgi import get_wsgi_application
[Tue Jul 16 10:42:33.386692 2019] [wsgi:error] [pid 6299:tid 139834262898432] [remote 10.72.15.5:3756] ImportError: No module named 'django'
[Tue Jul 16 10:47:48.994459 2019] [wsgi:error] [pid 6299:tid 139834212525824] [remote 10.216.63.3:3756] mod_wsgi (pid=6299): Target WSGI script '/home/local/user/wesupportapp/wesupportapp/wsgi.py' cannot be loaded as P$
[Tue Jul 16 10:47:48.994552 2019] [wsgi:error] [pid 6299:tid 139834212525824] [remote 10.216.63.3:3756] mod_wsgi (pid=6299): Exception occurred processing WSGI script '/home/local/user/wesupportapp/wesupportapp/wsgi.py$
[Tue Jul 16 10:47:48.994706 2019] [wsgi:error] [pid 6299:tid 139834212525824] [remote 10.216.63.3:3756] Traceback (most recent call last):
[Tue Jul 16 10:47:48.994734 2019] [wsgi:error] [pid 6299:tid 139834212525824] [remote 10.216.63.3:3756]   File "/home/local/user/wesupportapp/wesupportapp/wsgi.py", line 12, in <module>
[Tue Jul 16 10:47:48.994739 2019] [wsgi:error] [pid 6299:tid 139834212525824] [remote 10.216.63.3:3756]     from django.core.wsgi import get_wsgi_application
[Tue Jul 16 10:47:48.994764 2019] [wsgi:error] [pid 6299:tid 139834212525824] [remote 10.216.63.3:3756] ImportError: No module named 'django'
[Tue Jul 16 11:03:42.242236 2019] [wsgi:error] [pid 6299:tid 139834262898432] [remote 10.216.63.3:684] mod_wsgi (pid=6299): Target WSGI script '/home/local/user/wesupportapp/wesupportapp/wsgi.py' cannot be loaded as Py$
[Tue Jul 16 11:03:42.242345 2019] [wsgi:error] [pid 6299:tid 139834262898432] [remote 10.216.63.3:684] mod_wsgi (pid=6299): Exception occurred processing WSGI script '/home/local/user/wesupportapp/wesupportapp/wsgi.py'.
[Tue Jul 16 11:03:42.242464 2019] [wsgi:error] [pid 6299:tid 139834262898432] [remote 10.216.63.3:684] Traceback (most recent call last):
[Tue Jul 16 11:03:42.242485 2019] [wsgi:error] [pid 6299:tid 139834262898432] [remote 10.216.63.3:684]   File "/home/local/user/wesupportapp/wesupportapp/wsgi.py", line 12, in <module>
[Tue Jul 16 11:03:42.242489 2019] [wsgi:error] [pid 6299:tid 139834262898432] [remote 10.216.63.3:684]     from django.core.wsgi import get_wsgi_application
[Tue Jul 16 11:03:42.242509 2019] [wsgi:error] [pid 6299:tid 139834262898432] [remote 10.216.63.3:684] ImportError: No module named 'django'

【问题讨论】:

  • Apache 错误日志中有什么内容?
  • 嗨,丹尼尔,请问在哪里可以找到它
  • 好吧,我找到了,我会把它添加到问题中
  • 我认为它在环境中运行。如果你在那里检查你的日志,它显示它找不到 django 安装。

标签: django apache2 ubuntu-16.04 mod-wsgi


【解决方案1】:

就我而言,我忘记在虚拟环境中安装 Django。在这个虚拟环境中安装 Django

/home/local/user/wesupportapp/venv

【讨论】:

  • 嗨,Pranja,我认为是问题所在,我已经删除了虚拟环境并创建了一个新环境并在其上安装了 django,现在问题已解决。
猜你喜欢
  • 2011-08-08
  • 2023-02-23
  • 1970-01-01
  • 2018-06-07
  • 2016-08-31
  • 1970-01-01
  • 2015-09-30
  • 2017-07-09
  • 2017-09-05
相关资源
最近更新 更多