fogbound.net




Wed, 7 Sep 2005

Build PHP 5.0.5 for Mac OS X 10.4

— SjG @ 8:39 pm

I’m trying to track down a bug in my CMS Made Simple PHP code where I did something stupid with references (a rant on the PHP pass-by-value model available upon request). So it only manifests with PHP 4.4.x or PHP 5.0.5, since that’s where they finally decided to get strict with us idiot slackers. Neither of these are available as binary packages on Mac OS 10.4.

I was dismayed, shocked, stunned, dazed, and confused to learn that PHP was no longer a package for Fink. Dammit! Now I have to figure it out for myself. Crap.

With the help of a variety of pages out there on the web (especially this one), I was able to do it. Here’s how:

Install Fink, if you haven’t already. I use the “unstable” packages. Read the FAQ, and muck around with it for a while until you feel ready to proceed.

Install a wholehellovalotta packages using Fink:

  • libjpeg
  • libtiff
  • libpng
  • libxml2

I also installed the Fink version of MySQL server 4.1, client, and a bunch of shared libraries.

Next, gotta build ZLib:
curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/sw
make
(su if necessary)
make install

(I did my install work in /sw/src, but you could do it somewhere else if it pleases you more. Just take note of this other location when you need it later.)

Finally, we get PHP 5 .0.5 from http://us2.php.net/get/php-5.0.5.tar.gz/from/a/mirror

tar xzvf php-5.0.5.tar.gz
cd php-5.0.5
./configure --with-libjpeg=/sw --with-libtiff=/sw --with-libpng=/sw \
--with-gd --with-mysql=/sw --with-xml --with-apxs --with-exif \
--with-jpeg-dir=/sw --enable-exif --with-png-dir=/sw --with-zlib-dir=/sw \
--enable-embedded-mysqli
make
(su if necessary)
make install

Now, I already had a version of PHP installed before this, provided by Marc Liyanage’s excellent binary packages available at his page, so I didn’t need to tweak my php.ini file. If you do, you’d probably do something like:

cp /sw/src/php-5.0.5/php.ini-recommended /usr/local/lib/php.ini

and then edit into submission. You can also use the more general php.ini-dist instead of php.ini-recommended. I don’t know why they provide both — probably to confuse idiots like me. You’ll also need to register the PHP Mime Type with Apache. Edit your /etc/httpd/httpd.conf file, and add either to the general area or to a specific virtual host the line:

AddType application/x-httpd-php .php

Now test it! Create a test file in your web root containing:

<php phpinfo();>

and browse on over to it. With any luck, you’ll be greeted with ahappy PHP 5.0.5 banner.
Celebrate this with red wine. Preferably good red wine. Then get back to coding. As should be obvious, I decided to document instead of code, but I didn’t skip that vital red wine step.

Enjoy!


2 responses to “Build PHP 5.0.5 for Mac OS X 10.4”

  1. SjG says:

    I’ve been having some issues with the mysqli libraries. Changing the –enable-embedded-mysqli to –with-mysqli=/sw/bin/mysql_config seems to take care of that, but I can’t have both the –with-mysql and this explicit inclusion of mysqli without a conflict. So I dumped the –with-mysql=/sw

    I’ll report more if I make any other discoveries.

  2. SjG says:

    Actually, I should have posted this before. But the conflicts were due to SUE (Stupid User Error). I tried building a couple of times with different configuration settings. This final setting worked, but I had failed to do a “make clean” to clear out old, incompatible object files.

    So, in fact, you can compile with both the –with-mysql and the –with-mysqli=/sw/bin/mysql_config

    Just be sure to get rid of old object files if they’re in your source tree.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.