簡體   English   中英

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

[英]httpd mod_wsgi for python3.4 not working in 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): 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'

對於python3.4,mod_wsgi似乎存在一些問題。 檢查我是否嘗試過使用python2.7並使用pythyon2.7。

我無法在centos中找到python3.4的mod_wsgi包。 任何iseas如何解決這個????

這是我的apache conf

Listen 8080
# Django settings

WSGIDaemonProcess django_com user=apache group=apache processes=1 threads=10 python-path=/var/www/sample:/var/www/sample_env/lib/python2.7/site-packages
WSGIProcessGroup django_com
WSGIScriptAlias / /var/www/sample/sample/wsgi.py

<Directory /var/www/sample>
<Files wsgi.py>
    Require all granted
</Files>
</Directory>

要讓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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM