Navigate / search

How to enable PHP on OS X Mavericks

Having some free time this weekend, I thought I’d finish up on some of the tutorials needed to install WordPress on OS X Mavericks and later update them once the upcoming OS X Yosemite becomes available.

To run WordPress on a Mac running OS X Mavericks you’ll need PHP but after enabling Apache on OS X Mavericks, PHP is not enabled by default.

It’s actually pretty much smooth sailing to get PHP running on OS X Mavericks once you’ve gotten the Apache Web server software to work on the Mac. You’ll just need to edit a line in the Apache server config file httpd.conf which is located in the /etc/apache2 directory on OS X Mavericks.

Open the httpd.conf file using a text editor on the Mac – you can use the TextEdit app. Find the line containing the following text:

#LoadModule php5_module libexec/apache2/libphp5.so

You’ll notice that there’s a “#” character at the beginning of the line. Just delete the “#” character:

LoadModule php5_module libexec/apache2/libphp5.so

And save the edited httpd.conf file. Now, all that is needed is to restart the Apache web server and PHP will be enabled.

To test the setup, create a pinfo.php file in the /Library/WebServer/Documents directory of OS X Mavericks. The pinfo.php file contains:

<?php phpinfo(); ?>

Open the Safari web browser and enter the URL:

http://localhost/pinfo.php

If PHP is running properly, information about PHP on OS X Mavericks similar to the screenshot below will be displayed.

PHPinfo

Gerry Ilagan

Gerry Ilagan is into mobile apps and WordPress development at @speeqs. He loves to write about electronics, the Internet of Things, mobile phones, and #crazyideas.

Leave a comment

name*

email* (not published)

website