HOW TO: SETUP OS X LEOPARD FOR A LAMP DEVELOPMENT

28th March 2008

Before we start, LAMP = Linux, Apache, MySQL and PHP and yes I know Macs aren't Linux based, but FreeBSD is a flavour of Unix so it's close enough!

Having recently recieved my lovely new work Macbook Pro and have been setting it up for some serious PHP & MySQL development. Some of these stages were seriously difficult to find and it took myself and Sheldon Els (also on his shiny new Macbook Pro) a while to figure out; so we thought we would share..

As both of us work with a php framework (php-wax) we have to create custom installs of php, mysql and apache; mainly because the installed version of php does not support PDO or PEAR. Of course soon as you recompile php it generates a Darwin version of the shared object that Apache uses meaning Apache has to be re compiled also.

Firstly, wipe and reinstall your version of Leopard and remove all of those extra printer drivers and languages to save yourself over 5gb.

Do all of the software updates so any changes you do to the default locations are not over written by a security update.

I recommend creating a src folder within your user in to keep all of your source files.

Get your hands on the latest version of xcode and install it. This is needed by everything, as it has all the gcc utils required for compiling anything!

While xcode is downloading from the Apple Dev Center install all your standard applications (Quicksilver, Adium, Textmate etc).

As mentioned above some security updates will over write files in default system locations; meaning your custom setup will be lost. This guide will try to avoid such things and install to custom locations.

Anyway, time to get to work so crack open a terminal window and lets begin.

MySQL

That is MySQL setup and running, but to get it to start on boot you will need to copy the text below and save it to /Library/LaunchDaemons/com.mysql.mysqld.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>Program</key>
    <string>/usr/local/mysql_dev/bin/mysqld_safe</string>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Now run these commands to get MySQL to start at boot:

Also add the below line to you ~/.profile
    export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql_dev/bin:$PATH"

That is it! MySQL is sorted... NEXT!

PHP

PHP done and dusted... Almost finished..

Apache

That is everything up and running, not so hard when you know how!

COMMENTS

Thanks for this Charles, saved me a lot of digging around for answers. Cheers

Douglas Topalovic  2nd May 2008

Photo Viewer