(To read this in HTML, go to: http://dossy.org/archives/000586.html)

   In the "scratch your own itch" department, I decided to get
   Wordpress working under AOLserver. Wordpress is written in
   PHP, and while AOLserver can load PHP as a module, it doesn't play
   nice when you configure AOLserver with multiple virtual servers. The
   other option, running PHP as CGI using nscgi[1] and php-cgi, does
   work for the most part. However, there were a few issues I ran into
   that required changes to nscgi, which I'll outline below.

    [1] http://aolserver.com/sf/cvs/*checkout*/aolserver/nscgi/nscgi.html

Adding REQUEST_URI to CGI env. variables

   PHP expects an additional environment variable, REQUEST_URI, to be
   included on CGI requests. Of course, this isn't part of the
   CGI/1.1[2] specification. Basically, PHP expects REQUEST_URI to
   contain the Request-URI (from the HTTP/1.1[3] specification, see
   section 5.1.2). So, I added this in.

    [2] http://www.ietf.org/rfc/rfc3875
    [3] http://www.ietf.org/rfc/rfc2616

Mapping URLs to CGI with ns_register_cgi

   In order to map an URL to be handled by nscgi, you previously had to
   make the change in your config .tcl and restart AOLserver. One of the
   great things about AOLserver is the fact that you can modify some
   settings at runtime, without a restart. So, I looked at whether it
   would be possible to add additional mappings at runtime, and it
   appears that under the hood, nscgi also uses the Ns_RegisterRequest C
   API which is supposed to be safe to execute at runtime. So, I added a
   new Tcl command, ns_register_cgi, which is now part of nscgi. It is
   just a wrapper around CgiRegister, and thus takes the same argument.

   For example, if you wanted to map all requests to "/foo" (including
   "/foo/bar") to a PHP script "/var/www/myfoo.php", you would use
   something like this:

        foreach method {GET POST HEAD} {
            ns_register_cgi "$method /foo /var/www/myfoo.php"
        }

   This maps GET, POST and HEAD requests to URLs starting with "/foo" to
   the script specified.

   Caveat: It is currently possible to load the nscgi module multiple
   times in the same AOLserver process, for each virtual server. It is
   also possible to load it multiple times for the same virtual server.
   I'm not sure why anyone would do that, but it's possible. In that
   circumstance, the behavior of ns_register_cgi is undefined--as in, I
   haven't tested it. It may or may not work correctly. If you run such a
   configuration, where nscgi is loaded multiple times in the same
   virtual server, please test this carefully and share your findings.
   Thanks.

Where's the code?

   I've commited the changes to SourceForge CVS, both in HEAD (rev
   1.33[4], diff[5]) and the aolserver_v40_bp branch (rev 1.23.2.4[6],
   diff[7]).

    [4] 
http://aolserver.cvs.sourceforge.net/aolserver/aolserver/nscgi/nscgi.c?revision=1.33&view=markup
    [5] 
http://aolserver.cvs.sourceforge.net/aolserver/aolserver/nscgi/nscgi.c?r1=1.32&r2=1.33
    [6] 
http://aolserver.cvs.sourceforge.net/aolserver/aolserver/nscgi/nscgi.c?revision=1.23.2.4&view=markup
    [7] 
http://aolserver.cvs.sourceforge.net/aolserver/aolserver/nscgi/nscgi.c?r1=1.23.2.3&r2=1.23.2.4

-- 
Dossy Shiobara              | [EMAIL PROTECTED] | http://dossy.org/
Panoptic Computer Network   | http://panoptic.com/
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to