Get Apache & PHP working on Mac OS X 10.10 Yosemite


Three saviour commands

Start Apache
sudo apachectl start

Stop Apache
sudo apachectl stop

Restart Apache
sudo apachectl restart

Enable PHP
Open terminal and edit /etc/apache2/httpd.conf

sudo vi /etc/apache2/httpd.conf

Go to line # LoadModule php5_module libexec/apache2/libphp5.so and remove # and save the file and restart the server.

Document Root
Document Root is the folder where PHP files are shared and executed. By default in Yosemite Document Root is set to /Library/WebServer/Documents.

To change it to your custom location edit the /etc/apache2/httpd.conf again and make following lines

  • change DocumentRoot "/Library/WebServer/Documents" to DocumentRoot "/your/path/to/shared/folder"
  • change <Directory "/Library/WebServer/Documents"> to <Directory "/your/path/to/shared/folder">

save the file and restart the server.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s