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.

MySQL

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

First you need to get the release of MySQL from http://dev.mysql.com/downloads/ 

I selected Release: 5.5.9

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

 

/usr/local/mysql-VERSION

To start MySQL manually, run the following command:

$sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

Troubleshooting

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 
basedir=/usr/local/mysql

And change with:

if test -z "$basedir" then   
basedir=.
bindir=./bin

PHP

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

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

/private/etc/php.ini.default

naming it :

php.ini

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

Apache

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/libphp5.so

And change with:

LoadModule php5_module libexec/apache2/libphp5.so

Conclusion

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