Wednesday, January 28, 2009

MAMP on Leopard part III

The final part to MAMP is PHP. PHP is already installed but not configured. 

Apache needs to be told how to handle .php files (otherwise they are shown as plain text source in the browser). This handler needs to be added to /etc/apache2/httpd.conf, add near similar commands towards the end of the file.

AddType application/x-httpd-php .php

Also check whether the PHP module line is not commented, remove a # if present.

LoadModule php5_module libexec/apache2/

The PHP config file is not active by default, you will want to do this:

sudo cp /etc/php.ini.default /etc/php.ini

As you have installed MySQL, you will want PHP to be able to talk to it you need to edit two lines to ensure it actually works:

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

(Add the bold values) Then restart apache for the changes to take affect.

That completes this 3 part installation guide for MAMP on Leopard. P can also be Perl or Python, if you need those languages.