Yosemite Document Root

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