|
List Info
Thread: Problem trying to configure Django with FastCGI and Lighttpd
|
|
| Problem trying to configure Django with
FastCGI and Lighttpd |

|
2007-12-17 12:43:07 |
HI,
Does anyone have recent experience of setting of a Django
site with
FastCGI and Lighttpd?
We have a new dedicated server and have been trying to set
this up
without succcess.
Software:
Lighttpd 1.4.18
Flup 0.5
Django 0.97 pre-SVN (ie: current SVN trunk)
Excerpt from Lighttpd config:
----------------------
fastcgi.debug = 1
fastcgi.server = (
"/mysite_project.fcgi" => (
"main" => (
# Use host / port instead of socket for TCP
fastcgi
"bin-path" =>
"/home/myuser/mysite_project/www/mysite.fcgi",
"host" => "127.0.0.1",
"port" => 3303,
#"socket" =>
"/home/myuser/mysite_project/www/mysite.sock",
"check-local" =>
"disable",
"min-procs" => 2,
"max-procs" => 4,
)
),
)
alias.url = (
"/media/" =>
"/usr/local/django/contrib/admin/media/",
)
url.rewrite-once = (
# "^(/media.*)$" => "$1",
# "^/favicon.ico$" =>
"/media/favicon.ico",
"^(/.*)$" =>
"/mysite_project.fcgi$1",
)
------------------
mysite.fcgi file looks like this:
------
#!/usr/bin/python2.4
import sys, os
# Add a custom Python path.
sys.path.insert(0,
"/home/myuser_stage/mysite_project")
# Switch to the directory of your project. (Optional.)
os.chdir("/home/myuser_stage/mysite_project/")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] =
"mysite_project.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded")
--
When we start lighttd, it spawns 4 fastcgi processes, but on
visiting
the site url we just see:
---
Unhandled Exception
An unhandled exception was thrown by the application.
--
We've verified that Django is properly installed by testing
it with
its built in webserver - which works fine.
What are we doing wrong?
help!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem trying to configure Django
with FastCGI and Lighttpd |

|
2007-12-17 13:23:05 |
|
Take a look in the lighttpd server logs to see if there are any errors that might point you in the right direction.
The other thing is that you're running this threaded but you're spawning multiple processes. I suspect that could be causing problems too. Trying running it prefork and see if that helps.
-Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users googlegroups.com To unsubscribe from this group, send email to django-users-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: Problem trying to configure Django
with FastCGI and Lighttpd |

|
2007-12-17 13:54:52 |
|
Which version of django are you using? What do you see on lighttpd logs? Is port 3303 open with fcgi process?
Regards,
Martin Conte Mac Donell
On Dec 17, 2007 4:23 PM, Chris Moffitt <
chris  moffitts.n et">chris moffitts.net> wrote:
Take a look in the lighttpd server logs to see if there are any errors that might point you in the right direction.
The other thing is that you're running this threaded but you're spawning multiple processes. I suspect that could be causing problems too. Trying running it prefork and see if that helps.
-Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users googlegroups.com To unsubscribe from this group, send email to django-users-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: Problem trying to configure Django
with FastCGI and Lighttpd |

|
2007-12-17 14:10:10 |
How would I "run it prefork"? Sorry to be a dunce
- I'm a bit new to
this!
I checked the logs, nothing in the error logs since I made a
couple of
changes, thus:
fastcgi.server = (
"/mysite.fcgi" => (
"main" => (
# Use host / port instead of socket for TCP
fastcgi
"bin-path" =>
"/home/myuser_stage/mysite_project/www/mysite.fcgi"
;,
"socket" =>
"/home/myuser_stage/mysite_project/www/
mysite.sock",
"check-local" =>
"disable",
)
),
)
On Dec 17, 7:23 pm, "Chris Moffitt" <ch... moffitts.net> wrote:
> Take a look in the lighttpd server logs to see if there
are any errors that
> might point you in the right direction.
>
> The other thing is that you're running this threaded
but you're spawning
> multiple processes. I suspect that could be causing
problems too. Trying
> running it prefork and see if that helps.
>
> -Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem trying to configure Django
with FastCGI and Lighttpd |

|
2007-12-17 14:14:18 |
0.97-pre-SVN-6940
Nothing much in the logs.
I just tried telnet 127.0.0.1 3303 and I get connection
refused, so
maybe that is where the problem lies . . .
On Dec 17, 7:54 pm, "Martin Conte Mac Donell"
<refl... gmail.com>
wrote:
> Which version of django are you using? What do you see
on lighttpd logs? Is
> port 3303 open with fcgi process?
>
> Regards,
>
> Martin Conte Mac Donell
>
> On Dec 17, 2007 4:23 PM, Chris Moffitt <ch... moffitts.net> wrote:
>
>
>
> > Take a look in the lighttpd server logs to see if
there are any errors
> > that might point you in the right direction.
>
> > The other thing is that you're running this
threaded but you're spawning
> > multiple processes. I suspect that could be
causing problems too. Trying
> > running it prefork and see if that helps.
>
> > -Chris- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem trying to configure Django
with FastCGI and Lighttpd |

|
2007-12-17 15:00:11 |
|
In your mysite.fcgi script, just pass in the variable "prefork" instead of threaded.
The other thing you could try is to use the ip address instead of 127.0.0.1.
-Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users googlegroups.com To unsubscribe from this group, send email to django-users-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: Problem trying to configure Django
with FastCGI and Lighttpd |

|
2007-12-18 03:44:40 |
Interesting, I've changed my fcgi script to prefork, and
updated the
lighttpd conf to have the edternal IP address of the machine
and now
I'm getting a 403 - Forbidden error when I go to the site
URL.
I think one area of confusion (for me) is how and when to
start
Django's fcgi process.
Currently what I'm doing is starting lighttpd
(/etc/init.d/lighttpd
restatr) then starting Django's FCGI process as follows:
$ python manage.py runfcgi protocol=fcgi host=78.110.163.145
port=3303
Am I doing something wrong?
On Dec 17, 9:00 pm, "Chris Moffitt" <ch... moffitts.net> wrote:
> In your mysite.fcgi script, just pass in the variable
"prefork" instead of
> threaded.
>
> The other thing you could try is to use the ip address
instead of 127.0.0.1.
>
> -Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem trying to configure Django
with FastCGI and Lighttpd |

|
2007-12-18 11:59:55 |
Hi,
> Interesting, I've changed my fcgi script to prefork,
and updated the
> lighttpd conf to have the edternal IP address of the
machine and now
> I'm getting a 403 - Forbidden error when I go to the
site URL.
> I think one area of confusion (for me) is how and when
to start
> Django's fcgi process.
You start it one of two ways:
- Let lighttpd spawn it for you using the
"bin-path" parameter. From
your first post, this is what you were originally using.
- Start the FCGI process manually or through a script
that's
independent of lighttpd. That's the "python manage.py
runfcgi"
command...
> Currently what I'm doing is starting lighttpd
(/etc/init.d/lighttpd
> restatr) then starting Django's FCGI process as
follows:
> $ python manage.py runfcgi protocol=fcgi
host=78.110.163.145 port=3303
You need to listen on host=127.0.0.1 since that's where
your
lighttpd.conf is sending FCGI requests. Also, since you
don't need
Lighttpd to spawn your FCGI process, in lighttpd.conf,
remove the bin-
path, max-procs, etc. and leave only the host, port, and
check-local
parameters.
Since you're running your FCGI listener process on the same
server as
your lighttpd, you should communicate via the internal
loopback IP
address 127.0.0.1.
-Rajesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem trying to configure Django
with FastCGI and Lighttpd |

|
2007-12-18 12:05:57 |
Also, make sure you are using a recent release of flup
(either the
latest 0.5 update or the 1.0 release):
http://cheese
shop.python.org/pypi/flup/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-9]
|
|