To set up a web server with Apache and PHP on OS X Mountain Lion (10.8), you can follow these steps:
sudo apachectl start
http://localhost
in the address bar. You should see the Apache welcome page.PHP is not installed by default on OS X Mountain Lion, so you will need to install it manually. The easiest way to do this is by using the Homebrew package manager.
First, install Homebrew by entering the following command in the Terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install php
/etc/apache2/httpd.conf
) in a text editor:sudo nano /etc/apache2/httpd.conf
#LoadModule php5_module libexec/apache2/libphp5.so
Remove the #
symbol at the beginning of the line to uncomment it, then save the file and exit the text editor.
Restart Apache for the changes to take effect:
sudo apachectl restart
Now, you should be able to create PHP files in the Apache document root (/Library/WebServer/Documents/
) and access them through a web browser.
Note: These instructions are for OS X Mountain Lion (10.8). The steps may be different for other versions of OS X.