Tech Stuff06 May 2008 01:36 pm

Having used Leopard’s built in Ruby on Rails, I heard that the Apple guys also bundled Apache with PHP5. Here’s a quickstart on setting up and using them:
:update, where u see vi, you can replace with pico (a more friendly editor) if you don’t know vi, most commands in pick start with holding the control button.

-Open a Terminal(found in applications:Utilities)
-cd to /etc/apache2
-sudo vi httpd.conf (you’ll have to input the machine password)
-go the the line “#LoadModule php5_module libexec/apache2/libphp5.so” and remove the ‘#’
-back up a directory (cd ..) then copy the php default cfg file to a new one (sudo cp php.ini.default php.ini)
-optionally, to enable all error messages sudo vi that file and removed & ~E_NOTICE from the line starting with ‘error_reporting = E_ALL’

Now that PHP is configured, and Apache is configured to work with it, start apache:
-go to System Preferences (from apple in upper left of screen), click Sharing under Internet & Network
-check the box next to Web Sharing and close the preferences box
-now click the link under “Your computer’s website:” that will open your default browser to your document root.
-now to test php, go to “/Library/WebServer/Documents” and create a document there called info.php
-in that file paste: <?php phpinfo() ?>and save the file
-now to to http://localhost/info.php to see a php enabled page :)
FYI: There is a main apache webdoc location and there are user home locations. The httpd.conf calls, Include /private/etc/apache2/extra/httpd-userdir.conf which then includes Include /private/etc/apache2/users/*.conf which is associated with /Users/[name]/Sites/ rather then the more global /Library/WebServer/Documents

Trackback this Post | Feed on comments to this Post

Leave a Reply