Your Ad Here

How to Enable Apache HTTP Server with PHP in OS X [Mac Guide]

apache php and os x

Mac OS X (currently Leopard 10.5.3) includes an implementation of the Apache HTTP server. However, it isn’t running by default nor does it have the PHP engine enabled. This guide shows you how to activate Apache with PHP support in a few easy steps.

Enable the Apache PHP Module

Enabling PHP on the version of Apache that is distributed with OS X requires a minor change to the Apache configuration file. If you are not currently logged in as an administrator with sudo privileges open a terminal and do so now (substitute your administrator username for admin below).

su admin

Edit the Apache http.conf file using your favorite text editor. I use vim below.

sudo vim /etc/apache2/http.conf

Scroll down the configuration file until you find a commented line (comments are indicated by the # symbol) that begins as follows:

# LoadModule php5_module

Uncomment this line, save, and exit the editor.



Turn on the Apache HTTP Server and Test a PHP Page

To turn on Apache, navigate to System Preferences>Sharing. In the “Service” list check the box next to “Web Sharing” to turn Apache on. To test that Apache is running, open a web browser and type in the following URL substituting your username for yourname.

http://localhost/~yourname

A default Apache webpage should load. All of the files associated with your website are by default stored in the Sites directory in your home folder. Now create a PHP file in this directory in order to test that the PHP engine is working. Open a terminal and type the following:

echo <?php phpinfo(); ?> >> /Users/yourname/Sites/phpinfo.php

If PHP is working correctly, information about your installation of PHP should be displayed when the following URL is typed into you browser.

http//localhost/~yourname/phpinfo.php

That’s it. If you would like to now install MySQL on your Mac, I would encourage you to take a look at this post which also describes how to install a database for use with WordPress.




Trackbacks

close Reblog this comment
blog comments powered by Disqus

© Copyright Zaphu 2007. All rights reserved. -- Valid XHTML

Sitemap XML Sitemap XHTML