如何重建我的mod_wsgi以使用python 2.7.3?

时间:2013-05-31 09:25:05

标签: python apache mod-wsgi

我正在使用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 个答案:

答案 0 :(得分:5)

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

最有可能的简单:

$ ./configure
$ make
$ sudo make install

The mod_wsgi documentation详细介绍了这一点。

答案 1 :(得分:4)

我没有必要从源代码编译,这对我有所帮助:

$ apt-get remove libapache2-mod-python libapache2-mod-wsgi 
$ apt-get build-dep libapache2-mod-python libapache2-mod-wsgi 

答案 2 :(得分:2)

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

答案 3 :(得分: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>