stocksy.co.uk
"the site for those who crave disappointment"

Sponsored Links

PHP on Mac OS X

11th Jan 2005, 21:55:02

By James Stocks

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.

New Comments

Some Rights Reserved