Thursday, December 28, 2006

Installing PHP as CGI on Cygwin

For days of struggling to make PHP work on the Cygwin, I finally figure it out. I've installed Cygwin few years ago and apparently I've tried to install PHP on Cygwin before. Some of my left over setting on httpd.conf was screwing me over and over again for last few days. Here is the left over code:

AddHandler cgi-script .cgi .pl .php

It actually try to run .php file directly, not invoking PHP program. It gave me strange error on /var/log/apache/error_log that

line 1: ?php: No such file or directory

After removing .php extension on AddHandler, I've create php-cgi on /cgi-bin/ directory

#!/bin/sh
export PATH="/bin:$PATH"
win_page=`cygpath -w "$PATH_TRANSLATED"`
export PATH_TRANSLATED="$win_page"
php 2>&1

Found on www.cygwin.com/ml/cygwin/2002-05/msg00591.html via Google Cache. And added following line on httpd.conf file

AddType application/x-httpd-php .php
Action application/x-httpd-php "/cgi-bin/php-cgi"

No comments:

Post a Comment