Skip to content
Tags

,

Re-compiling PHP 5 for OS X

by admin on June 9th, 2009

This post is intended as a simple reminder for me to help me remember what I did when setting up a new PHP environment… help yourself to my notes, but you’re on your own if it breaks your server.

Here is a breakdown of what to install in what order… jpeg6, gd, libpng, mcrypt, mhash

Build the jpeg6 lib first- ftp://ftp.uu.net/graphics/jpeg/

I put the tar files in ~/_bin then I unpacked it with

tar -zxf [tarfile]

then moved the dir to /usr/local/php. Then CD into that dir and do the following:

cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared
make
sudo make install

Then you should recompile GD so it will see the new jpg6. Same thing, download GD to the ~/bin and untar it and move the dir to /usr/local/php.

./configure

You should see something like this:

Support for PNG library:          yes
Support for JPEG library:         yes
Support for Freetype 2.x library: yes
Support for Fontconfig library:   yes
Support for Xpm library:          yes
Support for pthreads:             yes

Then do this:
make
sudo make install
l

Now you will need libpng (http://www.libpng.org/pub/png/libpng.html). Untar it and move it to /usr/local/php

./configure
make
sudo make install

Now you need freetype and xpm… Im not going to try and figure out fonts so since fonts are already on the system you can use them this way in the config for php in just a few minutes.

–with-freetype-dir=/usr/X11R6 \
–with-xpm-dir=/usr/X11R6 \

Now for mcrypt and mhash. Go here and download the latest version of mcrypt ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/.  Same as the others, untar them and move them to /usr/local/php. CD into that dir then

./configure
make
sudo make install

And finally mhash. Go here and download it. http://sourceforge.net/project/showfiles.php?group_id=4286. Again, untar it and move it to /usr/local/php then

./configure
make
sudo make install

Now you are finally ready to compile PHP.

./configure --with-prefix=/usr \
--with-mandir=/usr/share/man \
--with-infodir=/usr/share/info \
--with-disable-dependency-tracking \
--with-apxs2=/usr/sbin/apxs \
--with-ldap=/usr \
--with-kerberos=/usr \
--with-enable-cli \
--with-gd \
--with-freetype-dir=/usr/X11R6 \
--with-xpm-dir=/usr/X11R6 \
--with-png-dir=/usr/local/lib \
--with-jpeg-dir=/usr/local/bin \
--with-tiff-dir=/usr \
--with-zlib-dir=/usr \
--with-enable-trans-sid \
--with-xml \
--with-enable-exif \
--with-enable-ftp \
--with-enable-mbstring \
--with-enable-mbregex \
--with-enable-dbx \
--with-enable-dbase \
--with-enable-trans-sid \
--with-enable-sockets \
--with-enable-wddx \
--with-enable-bcmath \
--with-iodbc=/usr \
--with-curl=/usr \
--with-config-file-path=/etc \
--with-sysconfdir=/private/etc \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mysql=/usr/local/mysql \
--with-pdo_mysql=/usr/local/mysql \
--with-openssl \
--with-xmlrpc \
--with-xsl=/usr \
--with-mcal=/usr/local/php \
--with-mcrypt=/usr/local/lib \
--with-mhash=/usr/local/lib \
--with-mime-magic \
--with-pear

I was able to run make fine, but when running make test I got an error…. After alot of digging around, I found this helpful post at php.net.

“After screwing around for an hour and screaming many profanities at my computer I looked back at the error and noticed:

/usr/local/mysql/lib/<b>mysql/</b>libmysqlclient.15.dylib

Why it was using this path I do not know, but I headslapped when I realised how simple it was! I solved the problem by creating a link called mysql that linked back on itself:

cd /usr/local/mysql/lib
sudo ln -s ./ mysql

Problem solved! I probably should have figured out why it was doing this instead, but this was easier and saved me from allot more frustration.”

This worked for me as well.

From → PHP

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS