Apache/PHP on OS X 10.9

Mysql Apache on Apple

I have a MAC Book pro and wanted to setup a web development environment.  This requires Apache, PHP, and MySQL.  Doing a quick search on the net revealed a few XAMMP distributions but I didn’t want them all tied together.  After looking through the Maverick (10.9.x) files system, I noticed that PHP and Apache are already installed.


Adding PHP to Apache


Even though PHP and Apache are included in Maverick, the Apache configuration that is distributed does not come with PHP enabled.  The first thing to do is enable PHP in the apache conf.  (you will need to edit it as thw root user).

Launch a terminal window and execute the following command:

sudo vi /etc/apache2/httpd.conf

Uncomment the following line and then save the file.

LoadModule php5_module libexec/apache2/libphp5.so

apache is not started by default.  You can start it up now with:

sudo apachectl start

You can now verify if PHP is installed and working.  Create an info.php file with the following command:

sudo echo ‘<?php phpinfo(); ?>’ > /Library/WebServer/Documents/info.php

Fire up your favorite browser and enter the following URL: http://localhost/info.php   You should see the php infomation page.



Leave a Comment

Your email address will not be published. Required fields are marked *