I have a Python Django site in one of my AWS Linux Server. First of all, let me tell you what I have done to host my Django app on my server. By default, the server has been installed with Python 2.6.9. For my application, I have compiled and installed Python 2.7.6 in a different location(/opt/python2.7.6). Still, the default python is 2.6.9. My application is under a virtual environment which has been created against this newly installed Python(2.7.6). My Web server is Apache2 (Version 2.4) and installed WSGI module by compiling the same against Python 2.7.6 using the below command.
./configure --with-python=/opt/python2.7.6/bin/python
I have configured apache accordingly and I am getting the following error. Kindly advice me how to resolve this issue.
[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"
I have tried many things to resolve this issue from google suggestions but not yet working.
Below is my apache conf file.
<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>
Please note, the site work well with standalone python runserver command.
Please let me know if any other details you need.
Thanks,