====== php ======
* download the source from http://www.php.net/downloads.php
===== Apache 2 Module and CLI PHP =====
==== My Preferred Libs ====
* first install [[apache2]], [[curl]], [[gd]], [[libjpeg]], [[libpng]], [[libxml2]], [[libmcrypt]], [[mysql]] (or mysqli), [[postgresql]], [[zlib]]
* :!: if you will be installing [[xdebug]], do NOT use the --disable-cli switch (has since been removed from below)
* :!: my most recent build-from-scratch project for php found that libxml2 is not required to be built and installed since Leopard includes it already, so php doesn't error out as shown below; this was built with Mac OS X 10.5.5
* On Lion, it looks like everything installs fine except the cli for php. It installed a file named php.dSYM in /usr/local/bin. This file seems to be the actual php executable, so fo r now I just created a symbolic link named php beside the php.dSYM file.
* see https://bugs.php.net/bug.php?id=43341
./configure \
--prefix=/usr/local \
--mandir=/usr/local/man \
--infodir=/usr/local/info \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-curl=/usr/local \
--enable-exif \
--enable-ftp \
--with-gd=/usr/local \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--with-zlib-dir=/usr/local \
--with-freetype-dir=/usr/local \
--with-mcrypt=/usr/local \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-libxml-dir=/usr/local \
--enable-zip \
--with-pgsql=/usr/local/pgsql \
--with-pdo-pgsql=/usr/local/pgsql \
--enable-mbstring
make
sudo make install
==== Leopard Update ====
:!:I had problems installing on Leopard with ld (when linking). The problem seems to be with libxml2. I installed my own libxml2, but Leopard has it's own. It seems like my headers were read, but it tried to link against Apple's older libraries. To fix it, do the following:
* attempt your build as before
* when you get to the point where the build process breaks (the very end, during linking with ld), copy the last gcc command (Warning: it is HUGE)
gcc -bundle -bundle_loader /usr/local/apache2/bin/httpd -L/usr/lib -L/usr/lib -laprutil-1 -lsqlite3 -lexpat -liconv -L/usr/lib -lapr-1 -lpthread -I/usr/include -g -O2 -L/usr/local/lib -L/usr/local/mysql/lib/mysql
...
-lz -lmysqlclient -lmcrypt -lltdl -liconv -lgd -lfreetype -lpng -lz -ljpeg -lcurl -lz -lm -lxml2 -lz -liconv -lm -lcurl -lssl -lcrypto -lldap -lz -lxml2 -lz -liconv -lm -lmysqlclient -lz -lm -lxml2 -lz -liconv -lm -lxml2 -lz -liconv -lm -lxml2 -lz -liconv -lm -lxml2 -lz -liconv -lm -o libs/libphp5.bundle && cp libs/libphp5.bundle libs/libphp5.so
* paste this into TextWrangler, and remove all references in the beginning of -L/usr/lib
* copy and paste this command back to the terminal, press enter, and your module should properly link
* type make again to confirm the build process is complete
* run sudo make install as usual
==== Trimmed down module version (no lib dependencies) ====
* first install [[apache2]]
./configure --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info --with-apxs2=/usr/local/apache2/bin/apxs --disable-cli
make
sudo make install
==== post install configuration ====
The apache configuration files should automatically be modified. If not, make sure you have the following in httpd.conf:
# this line should already have been added by the php install process
LoadModule php5_module modules/libphp5.so
# instead of this, add the lines in the following step to mime.types
# AddHandler php5-script php
Instead of the AddHandler line, add these lines to mime.types:
application/x-httpd-php php phtml
application/x-httpd-php-source phps
==== php.ini ====
If you want to control custom settings for php, create or edit php.ini in /usr/local/lib. If it doesn't exist, go into your php build directory and run this:
sudo cp php.ini-development /usr/local/lib/php.ini
=== enable debugging and error handling features ===
* display errors by default
display_errors=1
* show all errors, notices, and warnings
error_reporting=E_ALL
* log all php errors to a file
error_log=/usr/local/apache2/logs/phperror.log
log_errors=1
* see also [[xdebug]]
=== Installing PDFLib ===
- download PDFLib for Mac OSX from [[http://www.pdflib.com]] (at the time of this writing, the correct file name was PDFlib-7.0.3p5-MacOSX-10.5-Universal-php.dmg)
- open the disk image
- read up on the documentation (the doc folder)
- navigate to bind/php5/php-520 (read the install instructions, or continue with these steps if you are installing this exact version)
- create directory /usr/local/lib/php/extensions
- create directory /usr/local/lib/php/extensions/no-debug-non-zts-20060613
- copy the libpdf_php.so file to /usr/local/lib/php/extensions/no-debug-non-zts-20060613
- add the following to php.ini
extension=libpdf_php.so
- start or restart apache, and check a phpinfo page to verify that the module has loaded
==== starting and testing php ====
Start or restart apache, make a php page with the following to test the installation and configuration:
===== More CGI Help =====
see [[..:..:programming:php:php_cgi]]