Apache Webserver with PHP and MySQL

Mac OS X 10.6 ships with Apache as well as PHP5. This blog post describes how to activate it.


To run Apache: Enable Web Sharing in the System Preferences → Sharing. Websites are stored in /Library/WebServer/Documents/


To activate PHP: uncomment a line in /etc/apache2/httpd.conf:

LoadModule php5_module        libexec/apache2/libphp5.so

and restart Apache:

sudo apachectl restart


Go to http://dev.mysql.com/downloads/mysql/ and download the latest package of the x86, 64-bit DMG version of MySQL. Install mysql, the startup item and the preference pane. Then start MySQL in the preference pane and test it's working:


Now you have to adjust /etc/php.ini: replace the three occurences of /var/mysql/mysql.sock by /tmp/mysql.sock so it should look like:

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

Restart Apache

sudo apachectl restart