Goal: build and install php as a cgi program to interface with the Apache web server
In July of 2006, the Fink project stopped supporting the 10.4 transitional branch, and I needed to upgrade all of my Fink installed programs. In September, there was a mapping project that only worked with php as a cgi program. After removing all of the old files and installing Fink from scratch, I found that most things were available as pre-compiled binaries such as Apache2, but php was only available to build from source in the unstable branch.
Rather than open up the unstable branch for all programs, I opted to install everything else from stable binaries and build php from source. One advantage to using php as a cgi program is that I can upgrade Apache without having to rebuild php. One drawback is that performance speed is degraded.
It should be noted that the php binary included with Mac OS X is only a cli build (command line interface). You cannot complete the steps below using this binary. In order for the steps below to work, you must compile a php binary from source - in cgi mode, not cli.
The frustrating error that may show up if you try to use the wrong binary is an Internal Server Error from apache. The log might say “premature end of script headers.” Since your php binary wasn't built with cgi enabled, it doesn't generate proper html code, but rather plain text to be read in a terminal. The initial response from a proper cgi binary of php should contain “Content-type: xxxx/xxxx”
./configure --prefix=/sw --mandir=/sw/share/man --infodir=/sw/share/info --enable-force-cgi-redirect --with-config-file-path=/sw/etc/php4/cgi --with-gd=/sw --with-jpeg-dir=/sw --with-ldap=/sw --with-gettext=/sw --with-png-dir=/sw --with-zlib-dir=/sw --with-freetype-dir=/sw/lib/freetype2 --with-mcrypt=/sw --enable-fastcgi --enable-exif --without-mm --without-pgsql make
## php as cgi for all Action php4-script /cgi-bin/php AddHandler php4-script .php
<IfModule mod_dir.c> DirectoryIndex index.html index.htm index.php </IfModule>
* NOTE: it is possible that with this php install there are some needed features that were not enabled during the build process; this is the config command that fink was going to use for the unstable branch
configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking --with-apxs --with-ldap=/usr --with-kerberos=/usr --enable-cli --with-zlib-dir=/usr --enable-trans-sid --with-xml --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-dbx --enable-sockets --with-iodbc=/usr --with-curl=/usr --with-config-file-path=/etc --sysconf
* same steps as above, with the following modification to the configure command:
--with-mysql=/sw full command would then be: ./configure --prefix=/sw --mandir=/sw/share/man --infodir=/sw/share/info --enable-force-cgi-redirect --with-config-file-path=/sw/etc/php4/cgi --with-mysql=/sw --with-gd=/sw --with-jpeg-dir=/sw --with-ldap=/sw --with-gettext=/sw --with-png-dir=/sw --with-zlib-dir=/sw --with-freetype-dir=/sw/lib/freetype2 --with-mcrypt=/sw --enable-fastcgi --enable-exif --without-mm --without-pgsql