|
Some tips for getting PHP 5.2.6 running on Leopard.
Firstly, get MacPorts installed and add the following packages:
sudo port install tidy
sudo port install libiconv
sudo port install jpeg
sudo port install libpng
sudo port install zlib
sudo port install libmcrypt
sudo port install freetype
sudo port install openssl
sudo port install apache2
Then download the PHP source from php.net and extract.
The configure args I used to get PHP running happily on OS X 10.5 with all the extensions I want:
./configure \
--prefix=/Users/dmakovec/php \
--with-apxs2=/opt/local/apache2/bin/apxs \
--with-xsl=/usr \
--with-tidy=/opt/local \
--enable-mbstring \
--with-gd \
--with-jpeg-dir=/opt/local \
--with-png-dir=/opt/local \
--with-zlib-dir \
--enable-sockets \
--enable-exif \
--with-mcrypt=/opt/local \
--enable-soap \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql/bin/mysql_config \
--with-mysql-sock=/tmp/mysql.sock \
--with-freetype-dir=/opt/local \
--with-openssl=/opt/local \
--with-iconv=/opt/local \
--with-iconv-dir=/opt/local \
--enable-cli \
--with-mysqli=/usr/local/mysql/bin/mysql_config
Then run make && make install to get it going.
Gotcha: Iconv is used by some of the form validator methods in Zend Framework, so it's required. The configure help doesn't show a "--with-iconv=" option, but it appears to be required in order to get it to link correctly.
Gotcha: MySQL only provides Leopard binaries for Intel-based Macs. So for my Powerbook upgrade, I had to do a Macports based install:
port install mysql5 +server
sudo -u mysql mysql_install_db5
sudo -u mysql /opt/local/lib/mysql5/bin/mysqld_safe
/opt/local/lib/mysql5/bin/mysqladmin -u root password '[new_password]'
Then a little symlinking to get it to play nice with configure:
ln -s mysql5/mysql /opt/local/lib/mysql
ln -s mysql5/mysql /opt/local/include/mysql
Then changed the config string to:
./configure \
--prefix=/Users/dmakovec/php \
--with-apxs2=/opt/local/apache2/bin/apxs \
--with-xsl=/usr \
--with-tidy=/opt/local \
--enable-mbstring \
--with-gd \
--with-jpeg-dir=/opt/local \
--with-png-dir=/opt/local \
--with-zlib-dir \
--enable-sockets \
--enable-exif \
--with-mcrypt=/opt/local \
--enable-soap \
--with-mysql=/opt/local \
--with-pdo-mysql=/opt/local/lib/mysql5/bin/mysql_config \
--with-mysql-sock=/tmp/mysql.sock \
--with-freetype-dir=/opt/local \
--with-openssl=/opt/local \
--without-iconv \
--enable-cli \
--with-mysqli=/opt/local/lib/mysql5/bin/mysql_config
Gotcha: If you get the following error:
Undefined symbols:
"_res_nclose", referenced from:
_zif_dns_get_record in dns.o
_zif_dns_get_record in dns.o
_zif_dns_get_record in dns.o
"_res_nmkquery", referenced from:
_zif_dns_get_record in dns.o
"_res_ninit", referenced from:
_zif_dns_get_record in dns.o
"_res_nsend", referenced from:
_zif_dns_get_record in dns.o
ld: symbol(s) not found
It means there's a conflict with multiple installations of Bind being installed. I found that for some reason, the bind9 Macports package was installed on my system. I simply ran port uninstall bind9, removed the php directory and re-unzipped it, re-ran configure and make and all was good.
Oddly, while the PHP installer added the
extension=modules/libphp5.so
line to my httpd.conf, it forgot the
AddType application/x-httpd-php .php
line. Add this in to ensure PHP scripts get handled correctly
|