PHP and Mac OS X Leopard—A Warning
I have just upgraded my Mac PowerBook G4 laptop to Mac OS X 10.5 (Leopard). The installation went fine, but there are a couple of issues you need to be aware of if you use your Mac to develop PHP, as they could affect your decision to upgradeāat least for the time being.
Leopard installs Apache 2.2.6 instead of the Apache 1.3 series that was used in all previous versions of Mac OS X. As a result, when you restart your computer for the first time, web sharing will be disabled. Turning it on is exactly the same as described in all my books. However, if you use the Mac OS X PHP package from Marc Liyanage, it won’t work.
Although Marc offers an Apache 2 version on his site, that won’t work on Leopard, either. According to a post from Marc on 26 October in this thread in his forum, he needs to figure out how to integrate it all, but is currently very busy at work. The same thread discusses using the version of PHP preinstalled in Leopard. Apple has inexplicably decided to install PHP 4, even though it comes to the end of its support life in just over two months’ time. [Updated 28 Oct 2007] As Dan Brown points out below, PHP 5 is, indeed, preinstalled in Leopard. The confusion is caused by Apache being in a new location. I suspect that the old versions of Apache and PHP were left on my machines because they were upgraded from OS X 10.4, and that a completely fresh install of Leopard would have only Apache 2.2.6 and PHP 5.2.4.
Following Dan’s instructions below will get PHP 5 up and running in Leopard. However, the default installation of PHP doesn’t read php.ini. You need to create that yourself. I’ll try to get some instructions up on my site in the next day or two.
I have no idea how long it will take Marc Liyanage to work his usual wonders with his PHP package, but if you want to use Mac OS X to develop PHP sites, either delay upgrading to Leopard follow Dan’s instructions below or use the all-in-one package from MAMP. I have never used MAMP, but it has a good reputation. Perhaps it’s time for me to give it a try.
[Added 28 Oct 2007] MAMP seems to work without problem on Leopard, and is definitely worth considering if the idea of working in Terminal sends cold shivers up your spine. After downloading it, simply copy the MAMP folder to Applications, and then double-click the MAMP icon inside the MAMP folder. I suggest that you select Preferences > Ports, and click “Set to default Apache and MySQL ports”. If you do this, it’s important not to switch on Web Sharing in System Preferences. You must also close down any existing MySQL server. It’s also important to realize that the Apache and MySQL versions installed by MAMP are completely independent. The site root and MySQL data store are in different locations. Any databases created in a previous installation of MySQL must be exported, and reimported into the MAMP version of MySQL. The need to move things around detracts from the attraction of MAMP if you already have several databases stored in an existing installation of MySQL.
31 comments October 27th, 2007