So about that Mac development server on my local network. It’s an old Mac, an Intel dual core xeon. It runs OS X Server 10.6.8 which hasn’t had an update from Apple in at least a year I’m guessing. Which of course means PHP hasn’t been updated which is not good for a development server.
Even when you’re running a current version of OS X Server chances are your version of PHP is dated since Apple doesn’t exactly make that a priority. So in order to have at least a somewhat updated version of PHP you’re going to have to take matters into your own hands. Most sites agree it’s best to avoid any attempt at updating the PHP version that ships with the server as there could be any number of problems in doing so. That leaves installing the latest in a clean and different location.
You could head on over to php.net and grab the latest and compile it yourself. While I’m comfy enough within the guts of the OS, I’m not crazy abut the idea of spending an entire day doing this. Or as these things can go, a few days.
I’ve read where others opt to go the Homebrew route, which had I already been down that path before I’d probably give it a shot. Homebrew looks very interesting, but I’m not ready to commit to figuring it out.
Then I discovered there’s a “One Line Installation” method maintained by the good folks at liip.ch that is touted by many as the quickest and easiest way to upgrade PHP. Now you’re talkin’! Rather than copy and paste what they have on their site, just head on over to php-osx.liip.ch and check it out.
The install was pretty quick, and it makes no attempt to write over the PHP packaged with OS X Server, making an “undo” pretty easy as well should something not go well. However, it’s not quite a one line install. Oh the PHP installation was smooth, but not all was well after that single line was executed in terminal. An immediate refresh of a WordPress site failed with nothing more that the message Error establishing a database connection. So back to the search engines I go to try and diagnose the problem.
Cutting to the chase, here are the other steps I took to get things running again. All steps are done in terminal and you might try using pico to edit the files in question rather than vi.
In the apache config file httpd.conf found in /etc/apache2/ I added
LoadModule php5_module /usr/local/php5/libphp5.so
In the apache plist file org.apache.httpd.plist found in /System/Library/LaunchDaemons/ I added
<key>EnvironmentVariables</key>
<string>/usr/local/php5/</string>
And then changed
<key>Disabled</key>
<true/>
to false
I’m not totally convinced this was necessary but I found a site that seemed to think it was.
Lastly, the php.ini supplied with the new install had the mysql socket locations empty, leaving PHP in the dark on knowing where to find MySQL. For this you’ll need to know your particular installation and what the path to the socket is. My server is still running the old version of MySQL that Apple shipped (I know, bad bad boy). So the path for that is /var/mysql/mysql.sock. Go to /usr/local/php5/lib/ and edit php.ini making the following lines look like this:
pdo_mysql.default_socket = /var/mysql/mysql.sock
mysql.default_socket = /var/mysql/mysql.sock
mysqli.default_socket = /var/mysql/mysql.sock
If all went well you should be running again.
Leave a comment, or trackback from your own site.