[Twisted-web] twcgi.py changes

Stephen Thorne stephen at thorne.id.au
Tue Apr 13 08:20:46 MDT 2004


I had a change I made to twcgi ages ago  which I've just recently revised:

Old Issue:

New Patch:
--- twisted/web/twcgi.py        (revision 10536)
+++ twisted/web/twcgi.py        (working copy)
@@ -154,11 +154,20 @@
 class PHPScript(FilteredScript):
     """I am a FilteredScript that uses the PHP command on most systems.
     Sometimes, php wants the path to itself as argv[0]. This is that time.
+    To run as cgi, I require the following configuration options in php.ini be set:
+        cgi.fix_pathinfo = 1
+        cgi.force_redirect = 0
     filter = '/usr/bin/php4'
+class DebianPHPScript(PHPScript):
+    """PHP binary is in a different place in Debian"""
+    filter = '/usr/lib/cgi-bin/php4'
 class CGIProcessProtocol(protocol.ProcessProtocol, pb.Viewable):
     handling_headers = 1
     headers_written = 0

The doc changes are required imho, but I don't really like the subclass
for Debian.  Frankly, I think it sucks, but can anyone see a cleaner way
of doing this?

It almost feels like something that should be configured on runtime -
there are too many places the php4 variable could be (and we can't
exactly do a $PATH lookup, becuase php4-cli doesn't have all the cgi
stuff in it, and is in /usr/bin/php4 under debian systems).

Stephen Thorne

More information about the Twisted-web mailing list