Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My system:

CentOS: 5.5 x86_64 GNU/Linux
python 2.6.6
django 1.2.3

My file example.wsgi:

import os, site, sys

# add the virtual environment path

# fix (and potentially others) using stdout
sys.stdout = sys.stderr

#Calculate the path based on the location of the WSGI script.
project = os.path.dirname(__file__)
workspace = os.path.dirname(project)

os.environ['PYTHON_EGG_CACHE'] = '/home/admin/domains/'
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()

And Apache config:

ServerRoot /etc/httpd

<VirtualHost 69.*.*.*:80 >
LoadModule wsgi_module /usr/lib64/httpd/modules/

WSGIScriptAlias / /home/admin/domains/
WSGIDaemonProcess example user=admin processes=2 threads=25 display-name=%{GROUP}
WSGIProcessGroup example
WSGIApplicationGroup %{GLOBAL}

LogLevel debug

   <Directory /home/admin/domains/>
      Order allow,deny
      Allow from all

   Alias /robots.txt /home/admin/domains/
   Alias /static /home/admin/domains/

ErrorDocument 401 "Authentication Error"
ErrorDocument 403 "Forbidden"

 DocumentRoot /home/admin/domains/
 ScriptAlias /cgi-bin/ /home/admin/domains/

 UseCanonicalName OFF

 SuexecUserGroup admin admin
 CustomLog /var/log/httpd/domains/ bytes
 CustomLog /var/log/httpd/domains/ combined
 ErrorLog /var/log/httpd/domains/


I can do 'syncdb' and import whatever in PYTHONPATH. When I run, it's fine. But when i run, it has problems: Internal Server Error Debug in /var/log/httpd/domains/

[Sun Oct 03 00:01:08 2010] [error] [client] Premature end of script headers: example.wsgi
[Sun Oct 03 00:01:08 2010] [debug] mod_deflate.c(602): [client] Zlib: Compressed 498 to 210 : URL /500.shtml
[Sun Oct 03 00:01:08 2010] [debug] mod_headers.c(743): headers: ap_headers_output_filter()
[Sun Oct 03 00:01:08 2010] [debug] mod_headers.c(743): headers: ap_headers_output_filter()
[Sun Oct 03 00:01:09 2010] [info] mod_wsgi (pid=22379): Attach interpreter ''.

Please help me solve this problem. Thank you very much!

share|improve this question

2 Answers 2

Given that you can run your application normally, but it fails when you try to hit the admin interface, the odds are good that the ERROR 500 is being caused by an uncaught exception being raised. If you set DEBUG = True and TEMPLATE_DEBUG = True in you should get better information from the exception (such as a stack trace).

share|improve this answer

try this:


I've had a similiar problem, and I've solved it that way.

share|improve this answer
He's already doing that, with site.addsitedir('/home/admin/domains/') in the example.wsgi file. – Craig Trader Oct 3 '10 at 10:41

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.