By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,975 Members | 1,236 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,975 IT Pros & Developers. It's quick & easy.

Attempting to get lighttpd, fastcgi & python working

P: n/a
Hi folks,

I'm trying to get lighttpd, fastcgi & python working on a 2.4.21.x i686
linux system. I tried following the steps in:

http://www.cleverdevil.org/computing...i-and-lighttpd
Some of the lighttpd.conf setting are slightly different from those in
that article - fixing some erros in the original and accounting for
some change in entry formats itself.

All components were built by 'root' and binaries run by 'root'. Python
files (.py(c)) were deployed to '..../site-packages' and run with
execute prop turned on.

I'm trying to run lighttpd on "dev-1686linux.my.org:8090" with the
fastcgi server setup to listen on "127.0.0.1:8091". The problem I'm
having is that though lighttpd comes up and is able to serve static
content, it fails to bring up the WSGIServer and serve dynamic content
(simple "Hello World") generated by the py script (test.pcgi).

The errors I get are:
.....
[root@dev-i686linux myApp]# lighttpd -f ./lighttpd.conf

[root@dev-i686linux myApp]# Traceback (most recent call last):

File "/test/myApp/htdocs/test.fcgi", line 21, in ?
WSGIServer(myapp, bindAddress = ("127.0.0.1", 8091)).run()

File "/usr/lib/python2.4/site-packages/fcgi.py", line 1064, in run
sock = self._setupSocket()
Traceback (most recent call last):

File "/test/myApp/htdocs/test.fcgi", line 21, in ?
WSGIServer(myapp, bindAddress = ("127.0.0.1", 8091)).run()

File "/usr/lib/python2.4/site-packages/fcgi.py", line 1027, in
_setupSocket sock.bind(self._bindAddress)

File "/usr/lib/python2.4/site-packages/fcgi.py", line 1064, in run
sock = self._setupSocket()

File "/usr/lib/python2.4/site-packages/fcgi.py", line 1027, in
_setupSocket sock.bind(self._bindAddress)

File "<string>", line 1, in bind
socket.error: (98, 'Address already in use')

File "<string>", line 1, in bind
socket.error: (98, 'Address already in use')
....

It is unclear why it thinks the 127.0.0.1:8091 sock is already in use.
I ran this the first thing after a system reboot. No other apps are
using this port. I see this error no matter what port I choose, on the
server side. The browser sits there spinning and 'waiting' for the
response to url that incudes the .pcgi script.

The behviour is slightly different when I use UDSockets to listen on.
Again, I can see static content. When I try the py script, I see it
waiting indefinitely, but this time no errors are logged into the log
file. So no clue where it is hanging on the server side. The access
logs are not showing any "request" related entries even for the static
content that is being deliverd (albeit properly).

Can someone shed light on this. I thought if I can iron out this kink,
then I can get TurboGears (CherryPy ws) working with lighttpd and
fastcgi proxy-ing upfront.

Searched around quite a bit, but unable to find a clue. Would much
appreciate some pointers... Thanks a lot ...
/venkat
Following are the various config settings:

/test/myApp/lightpd.conf:
-------------------------
server.modules = (
"mod_rewrite",
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
server.document-root = "/test/myApp/htdocs/"
server.errorlog = "/var/tmp/lighttpd.error.log"
index-file.names = ( "index.html", "index.htm" )
server.port = 8090
server.bind = "dev-1686linux.my.org"
server.error-handler-404 = "/test.fcgi"
fastcgi.server = ( ".fcgi" =>
(
(
"host" => "127.0.0.1",
"port" => 8091,
"bin-path" =>
"/test/myApp/htdocs/test.fcgi",
"min-procs" => 1
)
)
)

/test/myApp/htdocs/test.fcgi:
-----------------------------
#!/usr/bin/python2.4
# test.fcgi for myApp

from fcgi import WSGIServer

def myapp(environ, start_response):

print 'got request: %s' % environ
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello World!\n']

# use a tcp-socket based approach
WSGIServer(myapp, bindAddress = ("127.0.0.1", 8091)).run()

/test/myApp/fcgi.py:
--------------------
The WSCGIServer (fcgi.py) authored by Saddi is from:
http://svn.saddi.com/py-lib/trunk/fcgi.py
No mods here.

Mar 24 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.