PHP on Mac OS X
11th Jan 2005, 21:55:02
The quick way...
Updated for Leopard, 25th April 2008.
Open a Terminal from /Applications/Utilities and type this:
sudo nano /etc/apache2/httpd.conf
Press control+w, then search for php. Remove the leading '#' from this line:
#LoadModule php5_module libexec/apache2/libphp5.so
Next, move to the end of the file and paste this in
<IfModule mod_php5.c> # If php is turned on, we repsect .php and .phps files. AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps DirectoryIndex index.html index.php </IfModule>
Go to System Preferences -> Sharing and start Web Sharing. Apache should start. See if PHP is working:
sudo -s echo "<? \ phpinfo(); \ ?>" > /Library/WebServer/index.php exit
Now browse to http://localhost. You should get a nice page telling you all about your newly PHP enabled Apache server.
For the MySQL part, see this separate article. If you'd rather roll your own Apache, have a look at this.