First Enable Apache:

  • System Preferences > Sharing
  • Check ‘Personal Web Sharing’

Then edit httpd.conf

  • sudo vi /etc/httpd/httpd.conf
  • locate these lines and remove the hashes in front:

#LoadModule php4_module
#AddModule mod_php4.c
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps

Download and install MySQL for the Mac (10.3, 10.4, etc)

  • http://dev.mysql.com/downloads/mysql/5.0.html
  • Type this into the terminal:

$ sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
$ mysql -u root mysql

  • Then set a password (changing “NewPw”, of course):

> update user set Password=password('NewPw‘) where User=’root’;
> flush privileges;

How to fix Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’
Apparently, OS X Tiger doesn’t allow for PHP MySQL connection out of the box. You get this: Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’
/etc/php.ini(.default) looks for mysql.sock in the wrong place… two options are to make a symbolic link from the right place to the socket…

$ sudo mkdir /var/mysql
$ sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

Or you can update your php.ini (.default) by finding “mysql.default_socket” and setting it to equal /private/tmp/mysql.sock and then restart apache with “apachectl graceful