PHP 5 under Mac OS X 10.5 Leopard

with 3 comments

### Apache

This weekend I installed Leopard on my work laptop. As Marc Liyanage’s installer is not working at the moment, so I had to do it the hard way. Fortunately, PHP 5 is already included in 10.5, so it’s just a matter of configuring things. Apple’s PHP is pretty slim and does not include all the modules Marc’s version has, but is enough for me as I do not use anything out of the ordinary.

First, edit the file /etc/apache2/httpd.conf e uncomment the line

LoadModule php5_module libexec/apache2/libphp5.so

In /etc, copy php.ini.default to php.ini. Edit the newly created php.ini as you wish: I didn’t change anything at first. Restart Apache, and PHP should be working. Create a test phpinfo() file and run it.

### Pear

If you did the phpinfo thing, you should see it was compiled with the flag “–without-pear”. Not a good thing, as I need some Pear modules. Visit http://pear.php.net/go-pear and copy (Cmd-A, Cmd-C) all the source you see.

In a terminal window type the following (don’t select and copy from here, you’ll overwrite the Pear source installer you copied previously).

pbpaste | sudo php

pbpaste is a neat utility which pastes the clipboard (pasteboard?) contents into the shell. We’re piping this output into PHP running as a super-user.

Follow the onscreen prompts, accept the modification to php.ini. The only default I didn’t accept was the directory where Pear gets installed. I opted to /usr/pear. Maybe I should have used /usr/local/pear…

Pear should be working now. Try to

/usr/pear/bin/pear install

### MySQL

I also need MySQL, and fortunately the 10.4 installer from MySQL.com works fine.

MySQL itself runs, but not without issues: the provided startup item and the System Prefs module do not work. To start MySQL in the shell use

sudo /usr/local/mysql/bin/safe_mysqld

I just had to change the “default_socket” setting PHP uses. By default, PHP looks for the socket somewhere under /var/. Edit /etc/php.ini and change the line:

mysql.default_socket = /tmp/mysql.sock

Restart Apache once again and you are done!

Written by admin

November 5th, 2007 at 3:18 pm

Posted in Apple

3 Responses to 'PHP 5 under Mac OS X 10.5 Leopard'

Subscribe to comments with RSS or TrackBack to 'PHP 5 under Mac OS X 10.5 Leopard'.

  1. Eu instalei o MAMP, não sabia que o Leopard já trazia o PHP5, excelente artigo.

    SoftWork

    5 Nov 07 at 4:05 pm

  2. A início só me ocorreu o MAMP (http://www.mamp.info/), mas depois arregacei as mangas e procurei mais fundo :)

    Pedro Cardoso

    5 Nov 07 at 5:23 pm

  3. [...] novo link [...]

Leave a Reply