Activating the bundled PHP server on Mac OS X (Snow Leopard)

Here is what I did on OS X 10.6.2, assuming that you already have bundled Apache web-server running – if not do this: Apple menu > System Preferences and click Sharing. Select the Web Sharing checkbox.)

1. Open up a terminal window and execute:

sudo nano /private/etc/apache2/httpd.conf

2. Uncomment – the line:

LoadModule php5_module libexec/apache2/<a href="" target="_blank"></a>

3. Add the following to handle php files:

<IfModule mod_php5.c>
# If php is turned on, we respect .php and .phps files.
AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps
# Since most users will want index.php to work we
# also automatically enable index.php
<IfModule mod_dir.c>
DirectoryIndex index.html index.php

4. Restart the web-server:

sudo apachectl graceful

5. My root folder for my webserver is: /Library/WebServer/Documents. Create a PHP test file (e.g. phptest.php) which contains one line:

<?php phpinfo(); ?>

6. Test PHP http://localhost/phptest.php

One thought on “Activating the bundled PHP server on Mac OS X (Snow Leopard)

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s