Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

my django.wsgi

import os
import sys

sys.path.append('/var/www/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
os.environ['PYTHON_EGG_CACHE'] = '/var/www/django/myapp/.python-eggs'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

http.conf

<VirtualHost 127.0.0.1:80>
    DocumentRoot /var/www/default
    ServerName localhost
    WSGIScriptAlias /myapp /var/www/django/myapp/apache/django.wsgi
    ErrorLog /var/www/django/myapp/logs/error_log
</VirtualHost>

The Apache error says the following

When i go to localhost/myapp then it gives some server error

[Fri Jun 25 12:42:42 2010] [error] [client 127.0.0.1] File does not exist: /var/www/default/favicon.ico
[Fri Jun 25 12:42:45 2010] [error] [client 127.0.0.1] File does not exist: /var/www/default/favicon.ico
[Fri Jun 25 12:42:48 2010] [info] [client 127.0.0.1] mod_wsgi (pid=3585, process='', application='localhost|/myapp'): Loading WSGI script '/var/www/django/myapp/apache/django.wsgi'.
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1] mod_wsgi (pid=3585): Target WSGI script '/var/www/django/myapp/apache/django.wsgi' cannot be loaded as Python module.
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1] mod_wsgi (pid=3585): Exception occurred processing WSGI script '/var/www/django/myapp/apache/django.wsgi'.
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1] Traceback (most recent call last):
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1]   File "/var/www/django/myapp/apache/django.wsgi", line 8, in <module>
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1]     import django.core.handlers.wsgi
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1]   File "/opt/python2.6/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 1, in <module>
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1]     from threading import Lock
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1]   File "/opt/python2.6/lib/python2.6/threading.py", line 13, in <module>
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1]     from functools import wraps
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1]   File "/opt/python2.6/lib/python2.6/functools.py", line 10, in <module>
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1]     from _functools import partial, reduce
[Fri Jun 25 12:42:48 2010] [error] [client 127.0.0.1] ImportError: /opt/python2.6/lib/python2.6/lib-dynload/_functools.so: failed to map segment from shared object: Permission denied

Output of ldd:

linux-gate.so.1 =>  (0x0098c000)
        libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00423000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x005cd000)
        libdl.so.2 => /lib/libdl.so.2 (0x00110000)
        libutil.so.1 => /lib/libutil.so.1 (0x006d8000)
        libm.so.6 => /lib/libm.so.6 (0x00778000)
        libc.so.6 => /lib/libc.so.6 (0x00a46000)
        /lib/ld-linux.so.2 (0x002e5000)

I tried import sys and there was no error in apace the only line was

[Mon Jun 28 13:33:24 2010] [info] [client 127.0.0.1] mod_wsgi (pid=19384, process='', application='python.localhost|/application'): Loading WSGI script '/var/www/application/application.wsgi'.
share|improve this question
    
You cut off the bottom of your error log. –  Ignacio Vazquez-Abrams Jun 25 '10 at 2:52
    
THis is the whole error log in my file –  John Jun 25 '10 at 3:13
add comment

3 Answers

up vote 0 down vote accepted

What platform? What exact version of Python is installed for the operating system? What exact version of Python is installed in /opt/python2.6? What do you get when you do 'ldd mod_wsgi.so' for installed mod_wsgi Apache module .so file? Are you by chance setting WSGIPythonHome in configuration?

Overall this looks a bit like you might be picking up Python shared libraries or installed Python lib directory for different versions and there is an incompatibility.

Also go back and get a hello world WSGI script working instead of Django and when that works add to it:

import threading

so you can see if you can create a standalone test that can be used to investigate what is happening separate to Django.

For hello world example see:

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

Finally, for good measure make sure you aren't loading mod_python in the same Apache instance.

share|improve this answer
    
Platform is CenOS 5 . BY Default the python is 2.4 but i have installed python 2.6 in /opt/python2.6. I have the another virtual host called python.localhost with Docroot /var/www/application and that is working fine. I have created other virual host called LOCALHOST for django and its not showing up. I followed all steps fron ur Google guide and it gives me this error. I am not at all loading mod_python. my django project is in /var/www/django/myapp and wsgi file is in myapp/apache. i added that import threading line in that hello world sript and i get same error . if i remove then it works –  John Jun 25 '10 at 7:37
    
But what does 'ldd mod_wsgi.so' yield? Also in the hello world, now add 'import sys; print >> sys.stderr, sys.prefix, sys.path'. Check Apache error logs for what they are set to. All up though you are better off taking this over to the mod_wsgi mailing list. A prior thread about this issue is at 'groups.google.com/group/modwsgi/browse_frm/thread/…;. Not sure though that we really sorted it out and person with issue seemed to vanish with no resolution. –  Graham Dumpleton Jun 25 '10 at 10:24
    
Thanks for your help , i will go to office monday and then i will do that –  John Jun 25 '10 at 11:31
    
I tried that and i have edited the post with new details –  John Jun 28 '10 at 4:03
add comment

does your webserver have write permissions to /var/www/django/myapp/.python-eggs ?

share|improve this answer
    
yes its 777 permission –  John Jun 25 '10 at 3:29
    
at the bottom of blog.dscpl.com.au/2010/03/… is an alternate. The only real difference I see is that you are appending the path, and Graham Dumpleton inserts the path. It looks to me like the path it is trying to include is a system path rather than a virtual environment, so, the script listed at the bottom of that post will probably fix it. –  karmawhore Jun 25 '10 at 3:53
    
i tried that and same error –  John Jun 25 '10 at 4:52
add comment

It would appear the problem can be solved by disabling SELinux, although not many people would go for that. Another is to try to set the appropriate permissions and contexts to the files trying to be accessed (don't ask me!)

Here (http://stackoverflow.com/questions/2685994/django-deploy-trouble) is a guy who seems to have solved the problem, but I haven't checked it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.