2017-05-13 101 views
0

我嘗試在Apache2中的Python 3.4部署Django的,但是發送錯誤500Apache2的蟒蛇3.4.3 Ubuntu的錯誤WSGI沒有模塊名爲

的Apache的error.log:

[Sat May 13 15:56:53.638802 2017] [mpm_event:notice] [pid 3610:tid 140692947613568] AH00489: Apache/2.4.12 (Ubuntu) mod_wsgi/4.3.0 Python/3.4.3+ configured -- resuming normal operations 
[Sat May 13 15:56:53.638897 2017] [core:notice] [pid 3610:tid 140692947613568] AH00094: Command line: '/usr/sbin/apache2' 
[Sat May 13 15:56:56.622523 2017] [wsgi:error] [pid 3613:tid 140692834260736] [remote 181.75.140.109:26259] mod_wsgi (pid=3613): Target WSGI script '/var/www/html/reportado-plataforma/reportalo/wsgi.py' cannot be loaded as Python module. 
[Sat May 13 15:56:56.622610 2017] [wsgi:error] [pid 3613:tid 140692834260736] [remote 181.75.140.109:26259] mod_wsgi (pid=3613): Exception occurred processing WSGI script '/var/www/html/reportado-plataforma/reportalo/wsgi.py' 
[Sat May 13 15:56:56.622646 2017] [wsgi:error] [pid 3613:tid 140692834260736] [remote 181.75.140.109:26259] Traceback (most recent call last): 
[Sat May 13 15:56:56.622842 2017] [wsgi:error] [pid 3613:tid 140692834260736] [remote 181.75.140.109:26259] File "/var/www/html/reportado-plataforma/reportalo/wsgi.py", line 12, in <module> 
[Sat May 13 15:56:56.622851 2017] [wsgi:error] [pid 3613:tid 140692834260736] [remote 181.75.140.109:26259]  from django.core.wsgi import get_wsgi_application 
[Sat May 13 15:56:56.622876 2017] [wsgi:error] [pid 3613:tid 140692834260736] [remote 181.75.140.109:26259] ImportError: No module named 'django' 

我安裝

sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3

我的虛擬主機:

WSGIScriptAlias//var/www/html/reportado-plataforma/reportalo/wsgi.py 
WSGIDaemonProcess reportalo python-path=/var/www/html/reportado-plataforma:/root/env/lib/python3.4/site-packages 
WSGIProcessGroup reportalo 
WSGIPassAuthorization On 

虛擬主機目錄:

<Directory /var/www/html/reportado-plataforma/reportalo> 
    <Files wsgi.py> 
     Require all granted 
    </Files> 
</Directory> 

我的環境:

appdirs==1.4.3 
Django==1.11.1 
django-cors-headers==2.0.2 
django-filter==1.0.2 
django-geoposition==0.3.0 
django-location-field==2.0.3 
djangorestframework==3.6.2 
djangorestframework-gis==0.11.1 
Markdown==2.6.8 
olefile==0.44 
packaging==16.8 
Pillow==4.1.1 
psycopg2==2.7.1 
pyparsing==2.2.0 
pytz==2017.2 
six==1.10.0 
uWSGI==2.0.15 

回答

2

運行Apache你的代碼是不太可能看到/root目錄下的東西的能力的用戶。通常只有root可以看到該目錄。將您的應用程序Python虛擬環境放置在別的地方。

還可以閱讀:

與mod_wsgi的建立Python的虛擬環境的推薦方式。按記錄使用python-home,而不是python-path

+0

謝謝,我創建一個用戶和問題解決了,我會繼續你的建議在python-home –

相關問題