7

我正在使用 mod_wsgi 来提供 django 网站,但我遇到了内部服务器错误。这是apache日志:

[Fri May 31 10:11:25 2013] [error] python_init: Python version mismatch, expected '2.7.2+', found '2.7.3'.
[Fri May 31 10:11:25 2013] [error] python_init: Python executable found '/usr/bin/python'.
[Fri May 31 10:11:25 2013] [error] python_init: Python path being used '/usr/lib/python2.7/:/usr/lib/python2.7/plat-linux2:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload'.
[Fri May 31 10:11:25 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Fri May 31 10:11:25 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Fri May 31 10:11:25 2013] [notice] Apache/2.2.22 (Ubuntu) DAV/2 mod_fcgid/2.3.6 mod_python/3.3.1 Python/2.7.3 mod_ssl/2.2.22 OpenSSL/1.0.1 mod_wsgi/3.3 mod_perl/2.0.5 Perl/v5.14.2 configured -- resuming normal operations

因此,mod_wsgi 版本和 python 的运行时版本似乎不匹配。我怎样才能更新这个?

4

4 回答 4

5

您必须从源代码编译 mod_wsgi 并重新安装。

很可能很简单:

$ ./configure
$ make
$ sudo make install

mod_wsgi 文档详细介绍了这一点。

于 2013-05-31T09:37:18.847 回答
4

我不必从源代码编译,这对我有帮助:

$ apt-get remove libapache2-mod-python libapache2-mod-wsgi 
$ apt-get build-dep libapache2-mod-python libapache2-mod-wsgi 
于 2014-01-22T15:21:59.713 回答
2

记得检查文件 wsgi.load 和 wsgi.conf 在 apache2 配置中是否仍然被引用。对于 Ubuntu(可能还有 Debian),这意味着有一个从 /etc/apache2/mods-available 到 /etc/apache2/mods-enabled 的符号链接。

于 2014-09-05T06:19:35.217 回答
2

有同样的问题,通过起诉虚拟环境解决。

设置:https ://www.digitalocean.com/community/tutorials/how-to-run-django-with-mod_wsgi-and-apache-with-a-virtualenv-python-environment-on-a-debian- vps 只需按照相同的步骤,在与我的 django 应用程序相同的文件夹中设置一个 virtualenv。

最终得到以下虚拟主机配置:

<Directory /storage/sandbox/www/django/sampleapp/static>
    Allow from all
    Order deny,allow
</Directory>
<Directory /storage/sandbox/www/django/sampleapp/media>
    Allow from all
    Order deny,allow
</Directory>
WSGIScriptAlias / /storage/sandbox/www/django/sampleapp/sampleapp/wsgi.py
WSGIPythonPath /storage/sandbox/www/django/sampleapp/:/storage/sandbox/www/django/env/lib/python2.7/site-packages
<Directory /storage/sandbox/www/django/sampleapp/sampleapp>
    <Files wsgi.py>
        Allow from all
        Order deny,allow
    </Files>
</Directory>
于 2014-11-19T14:55:00.970 回答