2016-03-21 25 views
0

AWS Linux Sunucumdan birinde bir Python Django sitesi var. Her şeyden önce, sunucumda Django uygulamamı barındırmak için ne yaptığımı size söyleyeyim. Varsayılan olarak, sunucu Python 2.6.9 ile kurulmuştur. Uygulamam için, Python 2.7.6'yı farklı bir yerde derledim ve yükledim (/opt/python2.7.6). Yine de varsayılan python 2.6.9. Uygulamam, bu yeni kurulan Python'a (2.7.6) karşı oluşturulmuş sanal bir ortamın altında. Web sunucum Apache2 (Sürüm 2.4) ve aşağıdaki komutu kullanarak Python 2.7.6'ya karşı aynısını derleyerek WSGI modülü kurdu.Yanlış Şekilde Yapılandırılıyor: Ara katman içe aktarılırken hata oluştu - Django wsgi hatası Apache

./configure --with-piton =/opt/python2.7.6/bin/python

Ben buna göre apacheyi yapılandırmış ve aşağıdaki hatayı alıyorum. Lütfen bu sorunu nasıl çözeceğimi öneriyorum.

[Mon Mar 21 10:38:32.669216 2016] [:info] [pid 26256] mod_wsgi (pid=26256): Create interpreter 'www.example.com|'. 
[Mon Mar 21 10:38:32.671113 2016] [:info] [pid 26256] mod_wsgi (pid=26256): Adding '/home/testuser/example.com' to path. 
[Mon Mar 21 10:38:32.671607 2016] [:info] [pid 26256] mod_wsgi (pid=26256): Adding '/home/testuser/venv/lib/python2.7/site-packages' to path. 
[Mon Mar 21 10:38:32.672621 2016] [:info] [pid 26256] mod_wsgi (pid=26256): Adding '/home/testuser/example.com/example' to path. 
[Mon Mar 21 10:38:32.681871 2016] [:info] [pid 26256] [client x.x.x.x:46626] mod_wsgi (pid=26256, process='www.example.com', application='www.example.com|'): Loading WSGI script '/home/testuser/example.com/example/wsgi.py'. 
[Mon Mar 21 06:38:33.341024 2016] [:error] [pid 26256] [client x.x.x.x:46626] mod_wsgi (pid=26256): Exception occurred processing WSGI script '/home/testuser/example.com/example/wsgi.py'. 
[Mon Mar 21 06:38:33.341297 2016] [:error] [pid 26256] [client x.x.x.x:46626] Traceback (most recent call last): 
[Mon Mar 21 06:38:33.341478 2016] [:error] [pid 26256] [client x.x.x.x:46626] File "/home/testuser/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__ 
[Mon Mar 21 06:38:33.341772 2016] [:error] [pid 26256] [client x.x.x.x:46626]  self.load_middleware() 
[Mon Mar 21 06:38:33.341926 2016] [:error] [pid 26256] [client x.x.x.x:46626] File "/home/testuser/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware 
[Mon Mar 21 06:38:33.342238 2016] [:error] [pid 26256] [client x.x.x.x:46626]  raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e)) 
[Mon Mar 21 06:38:33.342400 2016] [:error] [pid 26256] [client x.x.x.x:46626] ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "/home/testuser/venv/lib/python2.7/site-packages/psycopg2/_psycopg.so: undefined symbol: PyUnicodeUCS2_AsUTF8String" 

Bu sorunun Google önerilerinden çözümlenmesi için henüz bir işe yaramadı.

Aşağıda benim apache conf dosyam var.

<VirtualHost *:80> 
ServerName www.example.com 

DocumentRoot /home/testuser/example.com 
LogLevel info 
ErrorLog /home/testuser/http_error.log 
CustomLog /home/testuser/http_access.log combined 

WSGIDaemonProcess www.example.com processes=2 threads=15 display-name=%{GROUP} python-path=/home/testuser/example.com:/home/testuser/venv/lib/python2.7/site-packages 
WSGIProcessGroup www.example.com 

WSGIScriptAlias//home/testuser/example.com/example/wsgi.py 
Alias /media /home/testuser/site_assets/media 
Alias /static /home/testuser/example.com/.static_built 
<Directory /home/testuser/example.com/example> 
    <Files wsgi.py> 
     Order allow,deny 
     Allow from all 
    </Files> 
</Directory> 
</VirtualHost> 

, bağımsız piton runserver komutuyla iyi sitesindeki çalışmayı unutmayınız.

Lütfen ihtiyacınız olan başka bir ayrıntı varsa bana bildirin.

Teşekkürler,

+0

İlgili: http://stackoverflow.com/questions/2584198/undefined-symbol-pyunicodeucs2-decode-whilst-trying-to-install-psycopg2 ve http://stackoverflow.com/questions/25223993/ ithalat hatasız ephem-libastro çok da tanımlanmamış-sembol-pyunicodeucs2-asutf8string – SaeX

cevap

0

Çözüme kavuştum. Sunucumda çalışan üç Python sürümü (2.7.6, 2.6.9 ve 2.7.10) vardı, ancak varsayılan olarak 2.6.9 idi. Python sanal ortamım 2.7.6'ya karşı olmasına rağmen, Apache başvurum için bu python'u almadı. Bunun neden olduğunu bilmiyorum. Sanal ortam pythonuma işaret ederken ** WSGIPythonHome * eklediğimde, apache yapılandırma dosyamın en üstünde mükemmel çalıştı. Lütfen aşağıdaki güncelleştirilmiş apache yapılandırma dosyasına bakın.

WSGIPythonHome /home/testuser/venv 
<VirtualHost *:80> 
ServerName www.example.com 

DocumentRoot /home/testuser/example.com 
LogLevel info 
ErrorLog /home/testuser/http_error.log 
CustomLog /home/testuser/http_access.log combined 

WSGIDaemonProcess www.example.com processes=2 threads=15 display-name=%{GROUP} python-path=/home/testuser/example.com:/home/testuser/venv/lib/python2.7/site-packages 
WSGIProcessGroup www.example.com 

WSGIScriptAlias//home/testuser/example.com/example/wsgi.py 
Alias /media /home/testuser/site_assets/media 
Alias /static /home/testuser/example.com/.static_built 
<Directory /home/testuser/example.com/example> 
    <Files wsgi.py> 
     Order allow,deny 
     Allow from all 
    </Files> 
</Directory> 
</VirtualHost> 
İlgili konular