http://www2.jeffcroft.com/blog/2006/may/11/django-dreamhost/
I am trying to "Install and configure FastCGI"
I followed the tutorial, I don't see where I did anything wrong.
One part that I don't quite understand:
---
Set up mod_rewrite
Apache's mod_rewrite module will pass all requests to your website
through dispatch.fcgi, and thus, into Django's URL dispatcher.
----
How I am I supposed to do that? Is that done when I do the pkill
python?
After the pkill python, the tutorial states:
---
All URLs on our subdomain should now be routed to Django. Feel free to
open up your browser and try it out for yourself.
---
So, I don't have to restart python? Also, what am I supposed to see,
if the setup was successful? I gave it a try and the server timed out.
Any idea what I did wrong?
1. dispatch.fcgi
#!/home/myusername/python/bin/python
import os
import sys
from django.core.servers.fastcgi import runfastcgi
sys.path += ['/home/myusername/django']
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
runfastcgi(['method=threaded', 'daemonize=false'])
2. .htaccess (this is what you use to tell Apache to enable
mod_rewrite, note the . before the name)
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]
In my case, I have my Django projects/apps installed under ~/django,
and my Virtual Python installation in ~/python.
--------
Nathan Ostgard
In this directory
/home/walterbyrd/django.niche-software.com
I have these two files:
1. dispatch.fcgi
sys.path += ['/home/walterbyrd/django.niche-software/django/
django_src']
sys.path += ['/home/walterbyrd/django.niche-software/django/
django_projects']
from fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
WSGIServer(WSGIHandler()).run()
---------------
2. dispatch.fcgi
#!/usr/bin/env python
import sys
sys.path += ['/home/walterbyrd/django.niche-software/django/
django_src']
sys.path += ['/home/walterbyrd/django.niche-software/django/
django_projects']
from fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
WSGIServer(WSGIHandler()).run()
[niagara]$ ls -a
. .. .htaccess dispatch.fcgi django fcgi.py fcgi.pyc
[niagara]$ cat .htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
Also, make sure it does not have DOS mode CR-LF
And, do you have debug set in your settings.py?
Permissions are correct.
> Also, make sure it does not have DOS mode CR-LF
No DOS mode CR-LF.
> And, do you have debug set in your settings.py?
from settings.py
DEBUG = True
TEMPLATE_DEBUG = DEBUG
My file structure:
django.niche-software.com/
--- dispatch.fcgi
--- hello.fcgi
--- .htaccess
--- django/
------ django_media/
------ django_projects/
--------- myproject/
------------ settings.py
--------- sqlite-3.4.0
------ django_src/
------ django_templates
The hello.fcgi I got from the dreamhost wiki:
http://www.skweezer.net/bloglines/s.aspx/2/wiki.dreamhost.com/Special_~_Search?search=django&go=Go
The hello.fcgi looks like this:
#!/usr/bin/python2.3
from flup.server.fcgi import WSGIServer
def test_app(environ, start_response): start_response('200 OK',
[('Content-Type', 'text/plain')]) yield 'Hello, world!\n'
WSGIServer(test_app).run()
I tried running that, and got the same 500 error.
in the dreamhost control panel do you have the domain set up with
FastCGI support?
what about Extra Web Security?
> http://www.skweezer.net/bloglines/s.aspx/2/wiki.dreamhost.com/Special...
./dispatch.fcgi
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 301 MOVED PERMANENTLY
Content-Type: text/html; charset=utf-8
Location: /
> in the dreamhost control panel do you have the domain set up with
> FastCGI support?
> what about Extra Web Security?
>
Yes to both. And I went back and double checked.
Could you please also take a quick look into the error.log of your
domain right after accessing the test dispatch.fcgi which returned the
500 error? Perhaps there is something wrong with flup itself there :)
- Horst
So far I've tried just about every variation I could think of based on
Jeff Croft's tutorial, the Django page in the Dreamhost wiki, and the
Django docs on FastCGI.
I can't even get the FastCGI hello world example to work, so that's
what I'm concentrating on now. I opened a ticket with support, so
we'll see how that goes.
Pretty soon I'll just move to WebFaction or SliceHost, but I have a
lot of things up on Dreamhost, so it'd be nice to figure this out.