docs:programming:php:php_cgi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
docs:programming:php:php_cgi [2006/10/08 03:53] – (old revision restored) 127.0.0.1docs:programming:php:php_cgi [2008/08/03 00:25] (current) – external edit 127.0.0.1
Line 6: Line 6:
  
 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. 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.
 +
 +===== Apple's php binary =====
 +**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"**
 +
 +
 +
 +
 +
 +
 +
  
 ===== Setup ===== ===== Setup =====
   - Install Fink as usual   - Install Fink as usual
   - Install Apache2 binary   - Install Apache2 binary
-  - FIXME finish list of packages to install for our requirements for php - everything was installed via apt-get in binary form+  - binaries, development files, and shared libraries from the following may need to be installed before compiling php (use fink):
     * gd2     * gd2
     * libjepg     * libjepg
-    * libpng+    * libpng/libpng3
     * freetype2     * freetype2
-    * mcrypt+    * libmcrypt 
 +    * openldap (if you want ldap) 
 +    * gettext (req'd by phpldapadmin)
   - download php source from http://www.php.net (version used here was 4.4.4)   - download php source from http://www.php.net (version used here was 4.4.4)
   - extract the php archive, and build using the following commands:<code>   - extract the php archive, and build using the following commands:<code>
-./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-png-dir=/sw --with-zlib-dir=/sw --with-freetype-dir=/sw/lib/freetype2 --with-mcrypt=/sw --enable-fastcgi --enable-exif --without-mm --without-pgsql+./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 make
Line 27: Line 41:
 Action php4-script /cgi-bin/php Action php4-script /cgi-bin/php
 AddHandler php4-script .php AddHandler php4-script .php
 +</code>
 +  - modify the directory index:<code>
 +<IfModule mod_dir.c>
 +    DirectoryIndex index.html index.htm index.php
 +</IfModule>
 </code> </code>
   - restart apache or reboot and test a php script with the .php extension   - restart apache or reboot and test a php script with the .php extension
Line 32: Line 51:
 * 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<code> * 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<code>
 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 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
 +</code>
 +
 +===== Setup (using custom MySQL) =====
 +*  same steps as above, with the following modification to the configure command:<code>
 +--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
 </code> </code>
  • docs/programming/php/php_cgi.1160301234.txt.gz
  • Last modified: 2008/08/03 00:25
  • (external edit)