Being the recent (and appreciative) recipient of a MacBook I've been getting all the usual development tools installed. Everything went pretty much as expected until I got to where I wanted to compile PHP5. Not just any flavor of PHP5 but a snapshot of PHP 5.3. While this focuses on 5.3 you'd have to do the same song and dance for the PHP 5.2 source. Why?
If there is anything you should gleam from this article for future reference, Leopard comes with a 64bit Apache installation. Thus if I go into the PHP 5.3 source and tried, say:
#>./configure --with-png --with-tiff --with-jpeg \ --with-gd --enable-soap --with-apxs2
It my configure, may even compile but when you install and restart Apache you'd get errors about the PHP module being of the wrong architecture. I confirmed this using the "file" command. After that I started down the path of "well, let's just compile to 64 bit". I did find references that suggest trying to add CFLAGS="-arch x86_64" to your configure statement but that didn't work either. You might be able to get this working if you dink with it enough, however, I was in "get it working" mode. I did find this blog post by Marc Liyanage which gives more details into what is going on. Turns out this 64-bit problem is much bigger than just PHP because I was unable to get the fink libraries for stuff like libpng, etc to compile to 64bit. Now maybe you can do this by downloading the individual packages and compiling them one-by-one but I'm far too lazy for that.
The fix? Run Apache in 32-bit mode. Not knowing anything about Mac and that some binaries are compiled to support multiple architectures I was hanging out in #apache on irc.freenode.net trying to figure out the best way to compile Apache under OS X. At the same time I posted to macosxhints.com and got a very simple, elegant answer that didn't require me to download and recompile Apache:
sudo cp /usr/sbin/httpd /usr/sbin/httpd-fat sudo lipo /usr/sbin/httpd -thin i386 -output /usr/sbin/httpdAfter that using my standard ./configure worked just fine and I now have PHP 5.3a1 working beautifully. That said, I'd love to hear from anybody that has managed to get PHP 5.3 (and required libraries) compiled using the 64-bit Apache.
Comments (0)