0

My system:

CentOS: 5.5 x86_64 GNU/Linux
Apache/2.2.16
mod_wsgi-3.2-1.el5.x86_64
python 2.6.6
django 1.2.3

My file example.wsgi:

#!/usr/local/bin/python
import os, site, sys

# add the virtual environment path
site.addsitedir('/home/admin/domains/example.com/env/lib/python2.6/site-packages')
site.addsitedir('/home/admin/domains/example.com/myproject')
site.addsitedir('/home/admin/domains/example.com')

# fix markdown.py (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)
sys.path.append(workspace)

os.environ['PYTHON_EGG_CACHE'] = '/home/admin/domains/example.com/.python-eggs'
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/mod_wsgi.so

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

LogLevel debug

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

   Alias /robots.txt /home/admin/domains/example.com/public_html/robots.txt
   Alias /static /home/admin/domains/example.com/public_html/static


ErrorDocument 401 "Authentication Error"
ErrorDocument 403 "Forbidden"

 ServerName www.example.com
 ServerAlias www.example.com example.com 
 ServerAdmin [email protected]
 DocumentRoot /home/admin/domains/example.com/public_html
 ScriptAlias /cgi-bin/ /home/admin/domains/example.com/public_html/cgi-bin/

 UseCanonicalName OFF

 SuexecUserGroup admin admin
 CustomLog /var/log/httpd/domains/example.com.bytes bytes
 CustomLog /var/log/httpd/domains/example.com.log combined
 ErrorLog /var/log/httpd/domains/example.com.error.log

</VirtualHost>

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

[Sun Oct 03 00:01:08 2010] [error] [client 58.186.13.1] Premature end of script headers: example.wsgi
[Sun Oct 03 00:01:08 2010] [debug] mod_deflate.c(602): [client 58.186.13.1] 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!

2 Answers 2

1

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 settings.py you should get better information from the exception (such as a stack trace).

0

try this:

sys.path.append(project)

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

1
  • He's already doing that, with site.addsitedir('/home/admin/domains/example.com/myproject') in the example.wsgi file. Oct 3, 2010 at 10:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .