问题
I have a django (1.7) app that works pretty well on a Centos7 server. Now i moving to production server RHEL 6 and still have some issues.
The problem is the mod_wsgi.
The server config:
- RHEL6
- Apache 2.2
- Django 1.7
- Python 2.6
the apache error log
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] mod_wsgi (pid=12827): Target WSGI script '/home/evtdb/FLWeb/FLWeb/wsgi.py' cannot be loaded as Python module.
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] mod_wsgi (pid=12827): Exception occurred processing WSGI script '/home/evtdb/FLWeb/FLWeb/wsgi.py'.
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] Traceback (most recent call last):
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] File "/home/evtdb/FLWeb/FLWeb/wsgi.py", line 21, in <module>
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] from django.core.wsgi import get_wsgi_application
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] ImportError: No module named django.core.wsgi
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] mod_wsgi (pid=12827): Target WSGI script '/home/evtdb/FLWeb/FLWeb/wsgi.py' cannot be loaded as Python module.
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] mod_wsgi (pid=12827): Exception occurred processing WSGI script '/home/evtdb/FLWeb/FLWeb/wsgi.py'.
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] Traceback (most recent call last):
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] File "/home/evtdb/FLWeb/FLWeb/wsgi.py", line 21, in <module>
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] from django.core.wsgi import get_wsgi_application
[Fri Feb 20 11:18:39 2015] [error] [client 127.0.0.1] ImportError: No module named django.core.wsgi
the rest of the important files
flweb.conf
WSGIScriptAlias / /home/evtdb/FLWeb/FLWeb/wsgi.py
WSGIDaemonProcess localhost python-path=/home/evtdb/FLWeb:/usr/lib/python2.6/site-packages
WSGIProcessGroup localhost
<VirtualHost 127.0.0.1:8080>
<Directory /home/evtdb/FLWeb/FLWeb>
<Files wsgi.py>
Order allow,deny
Allow from all
</Files>
</Directory>
</VirtualHost>
wsgi.py
"""
WSGI config for FLWeb project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FLWeb.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
ldd modules/mod_wsgi.so
linux-vdso.so.1 => (0x00007fff6afff000)
libpython2.6.so.1.0 => /usr/lib64/libpython2.6.so.1.0 (0x00007fd69fc02000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fd69f9e5000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fd69f7e0000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007fd69f5dd000)
libm.so.6 => /lib64/libm.so.6 (0x00007fd69f359000)
libc.so.6 => /lib64/libc.so.6 (0x00007fd69efc4000)
/lib64/ld-linux-x86-64.so.2 (0x000000330aa00000)
I thought that a problem could be that mod_wsgi seems compiled with lib64, so I changed the python path on the flweb.conf to lib64 but it didn't worked
EDIT: I realize the server has python 2.7 in /user/local/lib and that is the python version where django is installed. I changed the path in the conf file, but now I guess I need to rebuild the mod_wsgi
EDIT2: Trying to rebuild mod_wsgi, have this problem
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
according to https://code.google.com/p/modwsgi/wiki/InstallationIssues is a conflict between python that was compiled to 32 bit and mod_wsgi to 64
来源:https://stackoverflow.com/questions/28635856/mod-wsgi-apache-error-with-django-app