How do I know if fastcgi is installed correctly? (using dreamhost)

819 views
Skip to first unread message

walterbyrd

unread,
Jul 18, 2007, 12:54:04 PM7/18/07
to Django users
I am trying to follow jeff croft's tutorial for installing django on
dreamhost.

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?

Nathan Ostgard

unread,
Jul 19, 2007, 2:48:48 AM7/19/07
to Django users
On DreamHost, in ~/mydomain.com I have two files:

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

walterbyrd

unread,
Jul 19, 2007, 2:04:59 PM7/19/07
to Django users
As I said, I tried to follow the tutorial:

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]


FrankW

unread,
Jul 19, 2007, 2:24:44 PM7/19/07
to Django users
A couple of things to check - what are the permissions on
dispatch.fcgi?
It needs to be executable, e.g. -rwxr-xr-x

Also, make sure it does not have DOS mode CR-LF

And, do you have debug set in your settings.py?

walterbyrd

unread,
Jul 19, 2007, 4:36:40 PM7/19/07
to Django users
On Jul 19, 12:24 pm, FrankW <fr...@zdecisions.com> wrote:
> A couple of things to check - what are the permissions on
> dispatch.fcgi?
> It needs to be executable, e.g. -rwxr-xr-x

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.


FrankW

unread,
Jul 19, 2007, 6:08:01 PM7/19/07
to Django users
in your shell, if you cd into /home/walterbyrd/django.niche-software/
django
and type ./dispatch.fcgi, what do you get?

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...

walterbyrd

unread,
Jul 19, 2007, 9:31:01 PM7/19/07
to Django users

On Jul 19, 4:08 pm, FrankW <fr...@zdecisions.com> wrote:
> in your shell, if you cd into /home/walterbyrd/django.niche-software/
> django
> and type ./dispatch.fcgi, what do you get?
>


./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.

Horst Gutmann

unread,
Jul 24, 2007, 6:27:49 PM7/24/07
to django...@googlegroups.com
walterbyrd wrote:
>
> On Jul 19, 4:08 pm, FrankW <fr...@zdecisions.com> wrote:
>> in your shell, if you cd into /home/walterbyrd/django.niche-software/
>> django
>> and type ./dispatch.fcgi, what do you get?
>>
>
>
> ./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: /
>

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

jfagnani

unread,
Jul 25, 2007, 6:10:04 PM7/25/07
to Django users
I'm having the same exact problem. Please keep us posted if you get
anywhere.

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.

Reply all
Reply to author
Forward
0 new messages