【问题标题】:Internal 500 error with Django: trying to set up mod_wsgiDjango 的内部 500 错误:尝试设置 mod_wsgi
【发布时间】:2015-01-07 22:17:25
【问题描述】:

我使用 django 创建了一个网站,并尝试使用我的 apache 服务器设置 mod_wsgi。

当我访问我的网站时,我收到此错误:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

这是我尝试设置 mod_wsgi 时得到的错误日志文件

[Wed Jan 07 16:08:01 2015] [error] [client 108.200.246.4] mod_wsgi (pid=18513): Target WSGI script '/var/www/firstweb/firstweb/wsgi.py' cannot be loaded as Python module.
[Wed Jan 07 16:08:01 2015] [error] [client 108.200.246.4] mod_wsgi (pid=18513): Exception occurred processing WSGI script '/var/www/firstweb/firstweb/wsgi.py'.
[Wed Jan 07 16:08:01 2015] [error] [client 108.200.246.4] Traceback (most recent call last):
[Wed Jan 07 16:08:01 2015] [error] [client 108.200.246.4]   File "/var/www/firstweb/firstweb/wsgi.py", line 13, in <module>
[Wed Jan 07 16:08:01 2015] [error] [client 108.200.246.4]     from django.core.wsgi import get_wsgi_application
[Wed Jan 07 16:08:01 2015] [error] [client 108.200.246.4] ImportError: No module named django.core.wsgi

下面是我的 httpd.conf 文件:

WSGIScriptAlias /mahi/ /var/www/firstweb/firstweb/wsgi.py
WSGIPythonPath /var/www/firstweb/ 

<Directory "/var/www/firstweb/firstweb">
<Files wsgi.py>
    Order allow,deny
    Allow from all
</Files>

</Directory>

请帮助我。我不知道去哪里。

【问题讨论】:

    标签: python django apache mod-wsgi


    【解决方案1】:

    看来python路径不完整。 如果您使用全局 Python 安装,在 ubuntu 中是这样的。

    WSGIPythonPath /var/www/firstweb/:/usr/local/lib/python3.4/dist-packages
    

    【讨论】:

      【解决方案2】:

      【讨论】:

      • @user3550366 那么你需要为你的项目和 django 所在的站点包提供路径,如下所示:/path/to/project:/path/to/site-packages/
      • 我应该把那个放在哪里?我对此真的很陌生。我很抱歉我的愚蠢问题。
      • @user3550366 就在 wsgialias 之前
      • 所以我在 wsgialis /var/www/firstweb: /usr/lib/python2.7/site-packages 的顶部添加了这个,对吗?
      • 我把它放在我的配置文件中,我得到一个错误 Invalid command '/usr/local/lib/python2.7/site-packages/'
      猜你喜欢
      • 2018-06-07
      • 2019-11-25
      • 2017-07-09
      • 2011-08-08
      • 1970-01-01
      • 2013-08-06
      • 2017-09-05
      • 2017-07-15
      • 2015-06-09
      相关资源
      最近更新 更多