This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cygwin/Apache with PHP CGI


Further to my problems with the Apache PHP module package I've given
up for the moment.

Instead I've downloaded the latest 4.2.0 Win32 native PHP ZIP file and
unzipped this into its own directory.

I've then made sure php-cli.exe, sapi\php.exe and php4ts.dll are in my
Windows PATH and copied php.ini-recommended to C:\WINNT\php.ini to get
the command line PHP working.

Finally, to use this from Cygwin/Apache I've commented out the PHP
LoadModule and AddModule lines and created a cgi-bin shell script to
run PHP via an Action line in htppd.conf.

httpd.conf:
	...
	#LoadModule php4_module lib/apache/libphp4.dll
	...
	#AddModule mod_php4.c
	...
	AddType application/x-httpd-php .php
	Action application/x-httpd-php "/cgi-bin/php-cgi"
	...

/var/www/cgi-bin/php-cgi: (or wherever your cgi-bin actually lives)
	#!/bin/sh
	export PATH="/bin:$PATH"
	win_page=`cygpath -w "$PATH_TRANSLATED"`
	export PATH_TRANSLATED="$win_page"
	php 2>&1

The crucial bit is converting PATH_TRANSLATED from Cygwin/Posix format
to Windows native for PHP.EXE to read.

Your PHP script will have to be written with the Windows native filing
system in mind so there are a few other variables that might benefit
from translation too if your script uses them. Cygwin is automatically
translating PATH but DOCUMENT_ROOT and SCRIPT_FILENAME might be needed
too. (Although I can't think why.)

(I appreciate that CGI is a sub-optimal way of using PHP in Apache but
at least this /is/ working for me and allows me to check my code more
easily before uploading to my service provider's Apache/PHP server.)

-- 
Sam Edge

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]