Reputation: 11994
I am trying to get a CherryPy app running under apache2/mod_wsgi on ubuntu. I am following the tutorial outlined here, and my config is almost identical. When visiting the root of the site, I receive a 500 Internal Server Error. The only error in the log is:
[Mon Dec 03 04:43:06 2012] [error] [client 64.189.251.239] Premature end of script headers: index.py
I have tried several variations to the tutorial, but I am not receiving any significant errors. Any ideas?
My Apache VirtualHost
:
...
WSGIScriptAlias / /var/www/example.com/uba/index.py
DocumentRoot /var/www/example.com/uba/
<Directory />
Options +ExecCGI Indexes FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example.com/uba/>
Options +ExecCGI -Indexes -FollowSymLinks -MultiViews
WSGIApplicationGroup %{GLOBAL}
AllowOverride All
Order allow,deny
allow from all
</Directory>
...
My index.py script:
#!/usr/bin/python
import sys
sys.stdout = sys.stderr
import atexit
import threading
import cherrypy
cherrypy.config.update({'environment': 'embedded'})
if cherrypy.__version__.startswith('3.0') and cherrypy.engine.state == 0:
cherrypy.engine.start(blocking=False)
atexit.register(cherrypy.engine.stop)
class Root(object):
def index(self):
return 'Hello World!'
index.exposed = True
application = cherrypy.Application(Root(), script_name=None, config=None)
UPDATE #1:
Running this very basic wsgi application produces the exact same error:
#!/usr/bin/python
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
Upvotes: 1
Views: 2553
Reputation: 4856
I suggest you test your apache configuration by replacing your cherrypy index.py script with a super simple wsgi app.
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
Make sure that works before trying to use a cherrypy script.
Upvotes: 2