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.

Apache

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

PHP

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

LoadModule php5_module        libexec/apache2/libphp5.so

and restart Apache:

sudo apachectl restart

MySQL

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:

/usr/local/mysql/bin/mysql

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:

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

Restart Apache

sudo apachectl restart

resources

Comments