Compiling PHP 5 on Mac OS X


Not that easy…

Note that the following will only work on Tiger, not on Panther nor Leopard!

1. Install Xcode; latest (currently 2.4) is always a good idea.

2. Install fink.

3. Install needed packages using fink:
sudo fink selfupdate
sudo fink install libjpeg libtiff libpng3 libxml t1lib5 uw-imap-c-client-ssl libmcrypt libmhash ming mysql15-dev postgresql80-ssl-dev

Note: Continue with the other steps while this process. It will take a while!
For step 7, wait for this to complete.

4. Download FrontBase for Mac OS X.
It comes in DMG/Installer form. Install it.
Note: You can customize the installation, and deselect everything except FBDeveloperLibraries.

5. Install FreeTDS:
curl -O http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
tar zxf freetds-stable.tgz
rm freetds-stable.tgz
cd freetds-0.64/
./configure && make && sudo make install
cd ..

6. Download latest PHP source; currently 5.2.5
Extract it.

7. Compile PHP
cd ~/Desktop/php-5.2.5
./configure --prefix=/usr/local/php5 --with-apxs --with-config-file-scan-dir=/usr/local/php5/php.d --with-iconv --with-openssl=/usr --with-zlib=/usr --with-gd --enable-gd-native-ttf --with-libjpeg=/sw --with-libtiff=/sw --with-libpng=/sw --with-jpeg-dir=/sw --with-png-dir=/sw --with-zlib-dir=/usr --with-ldap --with-xmlrpc --with-iconv-dir=/usr --with-snmp=/usr --enable-exif --enable-wddx --enable-soap --enable-sqlite-utf8 --enable-ftp --enable-sockets --enable-dbx --enable-dbase --enable-mbstring --enable-calendar --enable-bcmath --with-bz2=/usr --with-curl --with-kerberos=/usr --with-imap=/sw/share/c-client/ --with-imap-ssl=/sw/share/c-client/ --with-iodbc=shared,/usr --with-json=shared --enable-memcache --with-libxml --with-xsl --with-pgsql=/sw --with-pdo-pgsql=/sw --with-pdflib --with-t1lib=/sw --with-gettext --with-ming=/sw --with-mcrypt=/sw --with-mhash=/sw --with-mssql=/usr/local --with-mysql=/sw --with-mysqli --with-pdo-mysql=/sw --with-fbsql
OPTIM=-O2
make
sudo make install

8. Edit your /etc/httpd/httpd.conf: Change
<IfModule mod_php4.c>to
<IfModule mod_php5.c>
9. Restart Apache:
sudo apachectl stop
sudo apachectl start

You can verify that your new php executable works fine by doing:
/usr/local/php5/bin/php -i | grep "Build Date"
Done.

GD Star Rating
loading...
Share:
  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • FriendFeed
  • Reddit

5 Responses to “Compiling PHP 5 on Mac OS X”

  1. Matheus says:

    while configure in the php folder, i receive the error:

    checking for GNU gettext support… yes
    configure: error: Cannot locate header file libintl.h

    i can't find any solution in the net…

    if you know something about, please, send me!.. i'll try without gettext extension (for while), but is too important to me!..

    thank you for all..

  2. Daroost says:

    You need to reinstall gettext with Fink (or FinkCommander) and in the ./configure you need to specify –with-gettext=/sw

    That way the configure will go through normally.

    HTH ! :)

  3. Brian Warshaw says:

    What are FrontBase and FreeTDS for?

    • If you don't know, you probably don't need them.
      You can remove –with-fbsql and –with-mssql=/usr/local from the configure line.
      This will remove support for FrontBase and Microsoft SQL Server, both of which are database management systems.

      • Brian Warshaw says:

        Thanks! I knew what MSSQL was, and no, I have no desire to use it with my PHP installation on my Mac.

        Thanks again,
        Brian Warshaw

Leave a Reply