用于python3.4的httpd mod_wsgi不能在centos7中工作

Nij*_*jo 4 apache mod-wsgi python-3.4 centos7

我使用python3.4在centos7中运行Django应用程序.我正在使用apache进行webserver.我遇到以下错误:

[Tue Dec 05 09:48:17.048763 2017] [:error] [pid 8470] [remote 103.194.69.2:100] mod_wsgi(pid = 8470):目标WSGI脚本'/var/www/hello_world_django/hello_world_django/wsgi.py '无法加载为Python模块.[Tue Dec 05 09:48:17.049021 2017] [:error] [pid 8470] [remote 103.194.69.2:100] mod_wsgi(pid = 8470):处理WSGI脚本'/ var/www/hello_world_django/hello_world_django/wsgi发生异常的.py".[Tue Dec 05 09:48:17.049272 2017] [:错误] [pid 8470] [remote 103.194.69.2:100]回溯(最近一次电话会议):[Tue Dec 05 09:48:17.049383 2017] [:error] [pid 8470] [remote 103.194.69.2:100]文件"/var/www/hello_world_django/hello_world_django/wsgi.py",第13行,在[星期二05 09 09:48:17.049625 2017] [:错误] [pid 8470 ] [remote 103.194.69.2:100]来自django.core.wsgi import get_wsgi_application [Tue Dec 05 09:48:17.049661 2017] [:error] [pid 8470] [remote 103.194.69.2:100] File"/ var/www /virtual/lib/python3.4/site-packages/django/ init .py",第1行,在[Tue Dec 05 09:48:17.049711 2017] [:错误] [pid 8470] [remote 103.194.69.2:100 ]来自django.utils.version import get_version [Tue Dec 05 09:48:17.049735 2017] [:error] [pid 8470] [remote 103.194.69.2:100] File"/var/www/virtual/lib/python3.4 /site-packages/django/utils/version.py",第61行,在[星期二05 09 09:48:17.049777 2017] [:错误] [pid 8470] [remote 103.194.69.2:100] @ functools.lru_cache( )[Tue Dec 05 09:48:17.049901 2017] [:error] [pid 8470] [remote 103.194.69.2:100] AttributeError:'module'对象没有属性'lru_cache'

对于python3.4,mod_wsgi似乎存在一些问题.检查我是否尝试过使用python2.7并使用pythyon2.7.

我无法在centos中找到python3.4的mod_wsgi包.任何iseas如何解决这个????

这是我的apache conf

[Tue Dec 05 09:48:17.048763 2017] [:error] [pid 8470] [remote 103.194.69.2:100] mod_wsgi (pid=8470): Target WSGI script '/var/www/hello_world_django/hello_world_django/wsgi.py' cannot be loaded as Python module.
[Tue Dec 05 09:48:17.049021 2017] [:error] [pid 8470] [remote 103.194.69.2:100] mod_wsgi (pid=8470): Exception occurred processing WSGI script '/var/www/hello_world_django/hello_world_django/wsgi.py'.
[Tue Dec 05 09:48:17.049272 2017] [:error] [pid 8470] [remote 103.194.69.2:100] Traceback (most recent call last):
[Tue Dec 05 09:48:17.049383 2017] [:error] [pid 8470] [remote 103.194.69.2:100]   File "/var/www/hello_world_django/hello_world_django/wsgi.py", line 13, in <module>
[Tue Dec 05 09:48:17.049625 2017] [:error] [pid 8470] [remote 103.194.69.2:100]     from django.core.wsgi import get_wsgi_application
[Tue Dec 05 09:48:17.049661 2017] [:error] [pid 8470] [remote 103.194.69.2:100]   File "/var/www/virtual/lib/python3.4/site-packages/django/__init__.py", line 1, in <module>
[Tue Dec 05 09:48:17.049711 2017] [:error] [pid 8470] [remote 103.194.69.2:100]     from django.utils.version import get_version
[Tue Dec 05 09:48:17.049735 2017] [:error] [pid 8470] [remote 103.194.69.2:100]   File "/var/www/virtual/lib/python3.4/site-packages/django/utils/version.py", line 61, in <module>
[Tue Dec 05 09:48:17.049777 2017] [:error] [pid 8470] [remote 103.194.69.2:100]     @functools.lru_cache()
[Tue Dec 05 09:48:17.049901 2017] [:error] [pid 8470] [remote 103.194.69.2:100] AttributeError: 'module' object has no attribute 'lru_cache'
Run Code Online (Sandbox Code Playgroud)

Jim*_*ker 13

要让Python 3.4在CentOS中使用mod_wsgi,假设你从EPEL安装了Python 3.4(和pip),你可以这样做:

yum install httpd-devel (你需要这个mod_wsgi的pip安装才能工作)

pip3 install mod-wsgi

mod_wsgi-express install-module > /etc/httpd/conf.modules.d/02-wsgi.conf

  • 我不知道为什么这不在文档中,但应该如此。 (2认同)