How I got MySQL and PHP running on Leopard (in 3 easy steps)

Filed under Apple, Software on November 7th, 2007

As a programmer I rely on PHP and MySQL to get my web projects done (this blog included). Though I have upgraded to Leopard a week ago, I just took the time today to re-install my working environment. On Tiger it was a piece of cake, since I just used the wonderful packages fron entropy.ch to get PHP installed, and they worked fine with MySQL from mysql.com. Things are a little bit different in Leopard.

Here’s how it all went (try this at your own risk):

Installing PHP

You don’t need to. Seriously. Leopard includes PHP 5. To enable it you just have to edit: /private/etc/apache2/httpd.conf. In it, uncomment the line:

LoadModule php5_module libexec/apache2/libphp5.so

Having done that, restart Apache (by shutting down and re-starting Web Sharing from System Preferences->Sharing) and you’re done.

Installing MySQL

Just go to mysql.com and download the latest stable version. Since there are no Leopard packages there yet, I downloaded and installed the Intel .pkg installer for x86 of MySQL 5.0.45.You can ignore the preference pane since it does not work on Leopard (dunno why). To start mysql, and finish this setup, just follow these instructions (courtesy of the Angry-Fly):

First, start MySQL in a terminal window with the following command:

sudo /usr/local/mysql/bin/safe_mysqld

Then either close the terminal and open a new one, or just hit Command-N to open a new terminal window. Then type the following:

sudo mkdir /var/mysql/

And lastly, create a symbolic link to point the default socket file:

sudo ln -s /tmp/mysql.sock /var/mysql mysql.sock

Then…

That’s it. I did that and the built-in Apache worked fine with the built-in PHP 5 and the downloaded MySQL 5. However, keep in mind that the above instructions worked on a clean installation of Leopard. If you have upgraded to Leopard from your Tiger installation you’ll perhaps have to do things differently. Here are some different instructions that might help you.

tag icon

7 Responses to “How I got MySQL and PHP running on Leopard (in 3 easy steps)”

  1. Chris chandler Says:

    Angry-fly and I covered this almost simultaneously

    http://www.developingchris.com/2007/10/26/mysql-and-os-x-105-leopard/

  2. Sean Says:

    As part of the Darwin source, Apple has made a Leopard compatible MySQL available. I assume it is the version they are including with the server version. Sources are available here:

    http://www.opensource.apple.com/darwinsource/10.5/MySQL-43/

  3. Joannou Ng Says:

    Instead of manually starting MySQL between reboots, use launchd, as outlined here:
    http://blog.tomatocheese.com/archives/2007/11/1/migrating_mysql_to_mac_os_x_leopard/

  4. Bananaranha: the month in review [Bananaranha] Says:

    […] 7th, How I got MySQL and PHP running on Leopard (in 3 easy steps) [A short tutorial on enabling MySQL and PHP on OS X […]

  5. justlearning Says:

    hi i was trying to learn this whole thing…and umm what does uncommenting the line mean ? does that mean delete it ?

  6. justlearning Says:

    First, start MySQL in a terminal window with the following command:sudo /usr/local/mysql/bin/safe_mysql

    and what does that mean…can someone pls help

  7. bananaranha Says:

    hi i was trying to learn this whole thing…and umm what does uncommenting the line mean ? does that mean delete it ?

    No, it means *activating* it, by removing the # in the begining of the line. Just delete the “#”.

    First, start MySQL in a terminal window with the following command: sudo /usr/local/mysql/bin/safe_mysql

    This means: open Terminal (/Applications/Terminal.app) and in the terminal window that appears, write this command. It will ask for the administrator password. Enter it, and you’re done.

Leave a Reply