Installing Apache, PHP and MySQL on OSx

{jmstweet tweet_text="Installing Apache, PHP and MySQL on OSx" post_link="" download_link="" via_acc=""}There are excellent tutorials around the web about installing MySQL and PHP, here is my experience on this topic and how I solve it.


  • Remember to download DMG file
  • Install MySQL.prefPane .

First you need to get the release of MySQL from 

I selected Release: 5.5.9

After you install MySQL using the wizard, you could check the installation in:



To start MySQL manually, run the following command:

$sudo /Library/StartupItems/MySQLCOM/MySQLCOM start


When I installed the version 5.5.9 found

/usr/local/mysql/support-files/mysql.server: line 256: my_print_defaults: command not found

I fixed with

 vi /usr/local/mysql/support-files/mysql.server

Find the line with :

if test -z "$basedir" then 

And change with:

if test -z "$basedir" then   


Because PHP is already installed on leopard you must have to enable MySQL configuration

if no such file exists, then make a copy of :


naming it :


Edit the configuration file php.ini with:

vi /private/etc/php.ini

Find the line with :

mysql.default_socket =

And change with:

mysql.default_socket = /private/tmp/mysql.sock

Then find the line with:

mysqli.default_socket =

And change with:

mysqli.default_socket = /private/tmp/mysql.sock


You need to enable PHP

Edit the configuration file httpd.conf with:

vi /private/etc/apache2/httpd.conf

Find the line with:

# LoadModule php5_module libexec/apache2/

And change with:

LoadModule php5_module libexec/apache2/


I thought this is an easy solution to install Apache+MySQL+PHP, if you want to compile every Application try with ports this is more complex, but you learn a lot.