OS X Mountain Lion 10.8 Set Apache and PHP Web-Server

OS X Mountain Lion 10.8 Set Apache and PHP Web-Server

To set up a web server with Apache and PHP on OS X Mountain Lion (10.8), you can follow these steps:

  1. Install Apache:
  • Open the Terminal and enter the following command to start the Apache web server:
refer to:‮ruttual‬i.com
sudo apachectl start
  • To verify that Apache is running, open a web browser and enter http://localhost in the address bar. You should see the Apache welcome page.
  1. Install PHP:
  • 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)"
  • Next, install PHP using Homebrew:
brew install php
  1. Configure Apache to use PHP:
  • To enable PHP in Apache, open the Apache configuration file (/etc/apache2/httpd.conf) in a text editor:
sudo nano /etc/apache2/httpd.conf
  • Search for the following line:
#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.

Created Time:2017-10-30 10:17:52  Author:lautturi