2016-04-27 5 views
1

I python2.7.11 mit neu kompiliert haben zu stoppen:Unable Apache mit Systemversion von Python 2.7.6 statt virtualenv Version

./configure 
make 
make altinstall 
sudo ln -s /usr/local/bin/python2.7 /usr/local/bin/python 
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo /usr/local/bin/python 
sudo /usr/local/bin/easy_install pip 
sudo pip install virtualenv 
sudo pip install virtualenvwrapper 
source /usr/local/bin/virtualenvwrapper.sh 

ich django und alle Abhängigkeiten überprüfen, ob der pip befindet sich in meinem installiert habe neue python-Version

ich deinstalliert die verpackte Version von mod_wsgi und ich mod_wsgi auf die neue Version von python durch verknüpft haben:

./configure --with-python=/usr/local/bin/python 
make install 

Wenn ich neu starten beide 2.7.6 und 2.7.11 Apache scheinen gestartet werden:

[Wed Apr 27 01:46:21.085703 2016] [wsgi:warn] [pid 18410:tid 140116611360640] mod_wsgi: Compiled for Python/2.7.11. 
[Wed Apr 27 01:46:21.085775 2016] [wsgi:warn] [pid 18410:tid 140116611360640] mod_wsgi: Runtime using Python/2.7.6. 
[Wed Apr 27 01:46:21.086641 2016] [mpm_worker:notice] [pid 18410:tid 140116611360640] AH00292: Apache/2.4.7 (Ubuntu) OpenSSL/1.0.1f mod_wsgi/4.5.2 Python/2.7.6 configured -- resuming normal operations 

Mein httpd.conf wie folgt aussieht:

WSGIPythonHome /home/vagrant/.virtualenvs/django_2.7.11_env 
<VirtualHost *:80> 
    ServerName server.dev 
    ServerAlias www.server.dev 

    WSGIDaemonProcess server.dev python-path=/var/www/app:/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages 
    WSGIProcessGroup server.dev 

    ## Vhost docroot 
    DocumentRoot "/var/www/app" 
    Alias "/sitemap.xml" "/var/www/app/static/sitemap.xml" 
    <Directory /var/www/app/static> 
     Require all granted 
    </Directory> 


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

    ## Logging 
    ErrorLog "/var/log/apache2/av_app_nma_api_error.log" 
    ServerSignature Off 
    CustomLog "/var/log/apache2/av_app_nma_api_access.log" combined 

    WSGIScriptAlias//var/www/wsgi-scripts/wsgi.py 
</VirtualHost> 

ich in der Lage bin, die "Hallo Welt" wsgi laufen Anwendung, obwohl beide Versionen von Python verwendet werden. Wenn ich jedoch die django-App benutze, lande ich mit einem ImportError, der mit den verschiedenen Versionen zu tun zu haben scheint.

[Wed Apr 27 02:34:42.956988 2016] [wsgi:info] [pid 20244:tid 140656494913280] mod_wsgi (pid=20244): Adding '/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages' to path. 
[Wed Apr 27 02:34:42.957356 2016] [wsgi:info] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] mod_wsgi (pid=20244, process='server.dev', application='server.dev|'): Loading WSGI script '/var/www/wsgi-scripts/wsgi.py'. 
[Wed Apr 27 02:34:42.995218 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] mod_wsgi (pid=20244): Target WSGI script '/var/www/wsgi-scripts/wsgi.py' cannot be loaded as Python module. 
[Wed Apr 27 02:34:42.995328 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] mod_wsgi (pid=20244): Exception occurred processing WSGI script '/var/www/wsgi-scripts/wsgi.py'. 
[Wed Apr 27 02:34:42.995376 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] Traceback (most recent call last): 
[Wed Apr 27 02:34:42.995419 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/var/www/wsgi-scripts/wsgi.py", line 18, in <module> 
[Wed Apr 27 02:34:42.995945 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070]  from django.core.wsgi import get_wsgi_application 
[Wed Apr 27 02:34:42.995998 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/core/wsgi.py", line 2, in <module> 
[Wed Apr 27 02:34:42.996068 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070]  from django.core.handlers.wsgi import WSGIHandler 
[Wed Apr 27 02:34:42.996109 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 10, in <module> 
[Wed Apr 27 02:34:42.996209 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070]  from django import http 
[Wed Apr 27 02:34:42.996249 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/http/__init__.py", line 2, in <module> 
[Wed Apr 27 02:34:42.996316 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070]  from django.http.request import (
[Wed Apr 27 02:34:42.996355 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/http/request.py", line 10, in <module> 
[Wed Apr 27 02:34:42.996499 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070]  from django.core import signing 
[Wed Apr 27 02:34:42.996560 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/core/signing.py", line 48, in <module> 
[Wed Apr 27 02:34:42.996663 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070]  from django.utils.crypto import constant_time_compare, salted_hmac 
[Wed Apr 27 02:34:42.996705 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/utils/crypto.py", line 8, in <module> 
[Wed Apr 27 02:34:42.996792 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070]  import hmac 
[Wed Apr 27 02:34:42.996830 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/usr/local/lib/python2.7/hmac.py", line 8, in <module> 
[Wed Apr 27 02:34:42.997049 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070]  from operator import _compare_digest as compare_digest 
[Wed Apr 27 02:34:42.997102 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] ImportError: cannot import name _compare_digest 

Antwort @Graham: make misslingt mit folgenden:

/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC 
/usr/local/lib/libpython2.7.a: error adding symbols: Bad value 
collect2: error: ld returned 1 exit status 
apxs:Error: Command failed with rc=65536 
. 
make: *** [src/server/mod_wsgi.la] Error 1 

Antwort

0

Versuchen:

make distclean 
./configure --with-python=/usr/local/bin/python 
LD_RUN_PATH=/usr/local/lib make 
sudo make install 

Die LD_RUN_PATH Umgebungsvariable, wenn Gebäude bettet den Verzeichnispfad die richtige Bibliothek enthält, in der Suchpfad für die Datei mod_wsgi.so.

+0

Der Befehl make ist fehlgeschlagen. Ich habe den Fehler zur Frage hinzugefügt –

+0

Ihre Python-Installation ist nicht korrekt installiert und fehlt eine gemeinsame Bibliothek. Siehe http://modwsgi.readthedocs.org/en/develop/user-guides/installation-issues.html#mixing-32-bit-and-64-bit-packages und installiere deine Python-Installation neu, diesmal mit dem '' --openable-shared'' Option für '' configure'' von Python. Lesen Sie auch http://blog.dscpl.com.au/2015/06/installing-custom-python-version-into.html, das allgemeine Hinweise dazu enthält, wie Python bei der Installation entsprechend den Standardkonfigurationen richtig konfiguriert wird. –

+0

Nur ein Hinweis, ich habe es jetzt laufen vielen Dank ... aber wenn ich python mit dem - enabled-shared kompilieren die 2.7.11 Bibliotheken sind nicht geladen, dh/usr/local/bin/python -V gibt den Standard 2.6 .6. Der Ansatz, den Sie in Ihrem Blog beschreiben (kompilieren Sie zuerst mit --enable-shared und machen dann altbinstall ohne die --enable-shared dieses Problem. Könnte das der Grund sein, dass beide in den Distributionen installiert sind? Oder mache ich etwas anderes falsch? –

Verwandte Themen