The reason I decided to write this tutorial is that it seemed pretty clear to me that I would find myself going through this same process again, and probably many times (every few months) and it has proved to be very useful and time saving. Leopard comes with the apache web server pre-installed, but in this case, as a web developer I need to have control over which PHP etensions are installed, so I need to compile the web server and PHP with the relevant options.
-
Download, extract and compile Apache
First we’ll need to obtain the latest version of Apache Web server by going to http://httpd.apache.org/download.cgi. Download the latest Unix source of Apache (2.2.11 as of this writting) compressed in tar.gz format. Once that is complete open up a terminal window in the directory where you downloaded Apache and type the following commands:
$ cd /SourceCache/
$ curl -O http://ftp.udc.es/apache-dist/httpd/httpd-2.2.11.tar.bz2
$ tar -xjvf httpd-2.2.11.tar.bz2
$ cd httpd-2.2.11
$ ./configure --enable-layout=Darwin --enable-mods-shared=all
$ make
$ sudo make install
-
Download, extract and install IMAP client (required for php IMAP extension)
$ cd /SourceCache/
$ curl -O ftp://ftp.cac.washington.edu/imap/c-client.tar.Z
$ tar -zxvf c-client.tar.Z
$ cd imap-2007b
$ make oxp EXTRACFLAGS="-arch i386 -g -Os -pipe -no-cpp-precomp"
$ sudo cp c-client/*.h /usr/local/include/
$ sudo cp c-client/*.c /usr/local/lib
$ sudo cp c-client/c-client.a /usr/local/lib/libc-client.a
-
Download PHP source
$ cd /SourceCache/
$ curl -O http://www.php.net/distributions/php-5.2.8.tar.bz2
$ tar -xjvf php-5.2.8.tar.bz2 -
Install IMAP extension
$ cd /SourceCache/php-5.2.8/ext/imap/
$ sudo phpize
$ MACOSX_DEPLOYMENT_TARGET=10.5 \
CFLAGS="-arch i386 -g -Os -pipe -no-cpp-precomp" \
CCFLAGS="-arch i386 -g -Os -pipe" \
CXXFLAGS="-arch i386 -g -Os -pipe" \
LDFLAGS="-arch i386 -bind_at_load" \
./configure --with-kerberos --with-imap-ssl
$ sudo make
$ sudo make install
-
Compile PHP
$ cd /SourceCache/php-5.2.8
$ ./configure --enable-layout=Darwin --enable-mods-shared=all --prefix=/usr --mandir=/usr/share/man --localstatedir=/var --infodir=/usr/share/info --disable-dependency-tracking --with-apxs2=/usr/sbin/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=/private/etc --sysconfdir=/private/etc --with-mysql-sock=/var/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql --with-xmlrpc --with-xsl=/usr --with-pdo-mysql=/usr/local/mysql --enable-soap --with-pear --with-jpeg-dir=/usr/local/bin --with-png-dir=/usr/local/bin --with-gd=shared
$ make
$ sudo make install
-
Edit php.ini
Comment out extensions_dir in /private/etc/php.ini
Add following lines to /private/etc/php.ini:
extension=gd.so
extension=imap.so
-
Edit Apache config
Add following line to httpd.conf:
PHPIniDir /private/etc
-
Start the apache server
$ sudo apachectl start
Tags: Apache, cURL, GD, IMAP, Mac OSX Leopard, MySQL, PEAR, PHP, XMLRPC












