[Mapserver-users] Using PHP as CGI when compiled as DSO

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Thu Mar 18 08:43:53 PST 2004


> -----Original Message-----
> From: mapserver-users-admin at lists.gis.umn.edu 
> [mailto:mapserver-users-admin at lists.gis.umn.edu] On Behalf Of 
> Jason Thaxter
> Sent: 17 March 2004 18:37
> To: mapserver-users at lists.gis.umn.edu
> Subject: [Mapserver-users] Using PHP as CGI when compiled as DSO
> 
> 
> 
> Yet another way to run PHP CGI when compiled as a DSO and/or 
> free-standing language (but not as a CGI).
> 
> As usual:
> 	In httpd.conf:
> 		Action phtml-script /cgi-bin/php
> 		AddHandler phtml-script .phtml
> 
> 	This assumes that /cgi-bin is a ScriptAlias'd directory, e.g.:
> 		ScriptAlias /cgi-bin/ /path/to/cgi-bin
> 
> But:
> 	In the CGI directory, make php the following script:
> 		#!/bin/sh
> 		php -f $PATH_TRANSLATED
> 
> This assumes that php can be found in the $PATH under which 
> Apache runs. Make
> it:
> 	/path/to/your/php -f $PATH_TRANSLATED
> if in doubt...
> 
> I'm adding a note to the Wiki. Hopefully this Wiki page will 
> keep evolving for as long as PHP mapscript cannot run as a module.
> 
> Jason


Hi Jason,

Thanks for the hint! I couldn't get this to work as described above as I
found that PHP outputted headers and then appeared to barf :(. After a
lot of heartache, I found that I had to correct the SCRIPT_FILENAME CGI
parameter before it would work for me. My eventual CGI file looked like
this:

#!/bin/sh
export SCRIPT_FILENAME=$PATH_TRANSLATED
EXEC="/usr/bin/php -f $PATH_TRANSLATED"
$EXEC

After making this change, everything suddenly came to life. I don't know
if there was anything peculiar about the compile options which I should
have noticed that caused this problem, but the box was running RedHat
7.2 with Apache 1.3 and PHP 4.3.3.


Cheers,

Mark.

---

Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park
Derriford
Plymouth
PL6 8BX
England

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446


This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender. You
should not copy it or use it for any purpose nor disclose or distribute
its contents to any other person.





More information about the MapServer-users mailing list