Your mod_wsgi is compiled against a Python installation which isn't
the same as your virtual environment is created against.

Specifically one Python installation is compiled for UCS2 and the
other UCS4. One cant mix and match the two Python installations
compiled with different sizes for Unicode characters (UCS).

Confirm what Python installed mod_wsgi was compiled for:

http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library

You likely will need to rebuild mod_wsgi from source code against the
Python installation you are wanting to use rather than whatever the
prepackaged binary you are likely using at present is compiled for.

That or rebuild your own Python installation to use the same sorts of
options as the one mod_wsgi is compiled against so it is compatible.

You can see what options were used for each by looking at CONFIG_ARGS
value in lib/python2.7/config/Makefile of each Python installation.

Specifically pay attention to the ucs option for each Python
installation and how they are different.

Graham

On 5 July 2012 06:07, Peter Zakin <[email protected]> wrote:
> I've been struggling to deploy Django application on Amazon EC2 using
> Bitnami Djangostack for the last couple of days. When I go to my site I see
> the default bitnami page (/opt/bitnami/apache2/htdocs/index.html), however,
> when I open www.[site].com/[project_name] I get 'Internal Server Error'. But
> it's known that if mod_wsgi is setup correctly, the DocumentRoot value from
> httpd.conf is ignored, thus, I should see my Django application when
> accessing the site. Essentially, the main error is this - 'Target WSGI
> script cannot be loaded as Python module'. Two questions: 1) any ideas how
> to fix these mod_wsgi errors (the Apache logs are below)? 2) how to disable
> the default /opt/bitnami/apache2/htdocs/index.html page and show my homepage
> from django application when accessing the site? Thank you in advance!
>
> The details
>
> On my EC2 instance I"m running 64-bit Ubuntu 12.04 with DjangoStack 1.4-1.
> My Django project is located here -
> /opt/bitnami/apps/django/django_projects/[project_name].
>
> root@***:/opt/bitnami/apps/django/django_projects/***# ls
> manage.py README.md settings.py site_media users Procfile sandbox static
> test.py topics urls.py views.py __init__.pyc templates testviews.py
>
> Apache error logs (/opt/bitnami/apache2/logs/error_log):
> [Wed Jul 04 02:29:00 2012] [error] [client 140.180.6.212] File does not
> exist: /opt/bitnami/apache2/htdocs/favicon.ico
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212] mod_wsgi
> (pid=3990): Target WSGI script
> '/opt/bitnami/apps/django/scripts/django.wsgi' cannot be loaded as Python
> module.
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212] mod_wsgi
> (pid=3990): Exception occurred processing WSGI script
> '/opt/bitnami/apps/django/scripts/django.wsgi'.
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212] Traceback (most
> recent call last):
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]   File
> "/opt/bitnami/apps/django/scripts/django.wsgi", line 8, in <module>
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]     import
> django.core.handlers.wsgi
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]   File
> "/opt/bitnami/apps/django/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
> line 8, in <module>
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]     from django
> import http
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]   File
> "/opt/bitnami/apps/django/lib/python2.7/site-packages/django/http/__init__.py",
> line 119, in <module>
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]     from
> django.http.multipartparser import MultiPartParser
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]   File
> "/opt/bitnami/apps/django/lib/python2.7/site-packages/django/http/multipartparser.py",
> line 13, in <module>
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]     from
> django.utils.text import unescape_entities
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]   File
> "/opt/bitnami/apps/django/lib/python2.7/site-packages/django/utils/text.py",
> line 4, in <module>
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]     from gzip
> import GzipFile
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]   File
> "/opt/bitnami/python/lib/python2.7/gzip.py", line 10, in <module>
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]     import io
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]   File
> "/opt/bitnami/python/lib/python2.7/io.py", line 60, in <module>
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212]     import _io
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212] ImportError:
> /opt/bitnami/python/lib/python2.7/lib-dynload/_io.so: undefined symbol:
> PyUnicodeUCS2_AsEncodedString
> [Wed Jul 04 02:29:15 2012] [error] [client 140.180.6.212] File does not
> exist: /opt/bitnami/apache2/htdocs/favicon.ico
> [Wed Jul 04 02:44:00 2012] [error] [client 140.180.6.212] File does not
> exist: /op
>
> Let me quickly introduce the contents of the files to make the case more
> concrete.
> This is my /etc/apache2/sites-available/default file
>
> <VirtualHost *:80>
> ServerAdmin root@***
> ServerName ***
>
> Alias /site_media/ /opt/bitnami/apps/django/django_projects/***/site_media/
> Alias /static/
> /opt/bitnami/apps/django/lib/python2.7/site-packages/django/contrib/admin/static/
> Alias /robots.txt
> /opt/bitnami/apps/django/django_projects/***/site_media/robots.txt
> Alias /favicon.ico
> /opt/bitnami/apps/django/django_projects/***/site_media/favicon.ico
>
> CustomLog "|/usr/sbin/rotatelogs
> /opt/bitnami/apps/django/django_projects/logs/access.log.%Y%m%d-%H%M%S 5M"
> combined
> ErrorLog "|/usr/sbin/rotatelogs
> /opt/bitnami/apps/django/django_projects/logs/error.log.%Y%m%d-%H%M%S 5M"
> LogLevel warn
>
> WSGIProcessGroup [***.com]
> WSGIScriptAlias / /opt/bitnami/apps/django/scripts/django.wsgi
>
> <Directory /opt/bitnami/apps/django/django_projects/***/site_media>
> Order deny,allow
> Allow from all
> Options -Indexes FollowSymLinks
> </Directory>
>
> <Directory /opt/bitnami/apps/django/django_projects/***/conf/apache>
> Order deny,allow
> Allow from all
> </Directory>
> </VirtualHost>
> This is my /opt/bitnami/apps/django/scripts/django.wsgi file
> import os, sys
>
> sys.path.append('/opt/bitnami/apps/django/lib/python2.7/site-packages/')
> sys.path.append('/opt/bitnami/apps/django/django_projects')
> sys.path.append('/opt/bitnami/apps/django/django_projects/***')
> os.environ['DJANGO_SETTINGS_MODULE'] = '***.settings'
>
> import django.core.handlers.wsgi
>
> application = django.core.handlers.wsgi.WSGIHandler()
> Here is the relevant portion of /opt/bitnami/apache2/conf/httpd.conf file:
> ServerRoot "/opt/bitnami/apache2"
> Listen 80
> ServerName [***.com]
> DocumentRoot "/opt/bitnami/apache2/htdocs"
> LoadModule wsgi_module modules/mod_wsgi.so
> WSGIPythonHome /opt/bitnami/python
> Include "/opt/bitnami/apache2/conf/ssi.conf"
> Include "/opt/bitnami/apps/django/conf/django.conf"
> Include "/opt/bitnami/apache2/conf/bitnami/httpd.conf"
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/modwsgi/-/QPDJ_jHHYqIJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to