Enabling PHP on Mac OS X 10.4 (Tiger)

I didn't see a simple solution, so here it is.

  1. Start the Apache web server as follows
    1. Bring up System Preferences. It is available under the Apple menu.
    2. Click on Sharing
    3. Make sure "Personal Web Sharing" is checked on the left. On the right, it should say "Personal Web Sharing On"
    4. You should see a message below saying "View this computer's web site at [first link] or your personal website at [second link].
    5. Click on [first link]. Safari should come up with the Apache logo and a message saying the installation of the Apache web server was successful.
    6. Go back to System Preferences and click on [second link]. Safari should come forward with a big "X Your website here."
  2. Edit httpd.conf
    1. Bring up a terminal window. (Terminal is located in "Applications" under "Utilities".)
    2. cd to /etc/httpd/
    3. Bring up httpd.conf in read-write mode in your favorite editor.  I did this by doing "su [username]" where [username] is an administrator and then doing "sudo emacs httpd.conf".
    4. Find the line that says "#LoadModule php4_module" and uncomment it. (Remove the "#" from that line.)
    5. Find the line that says "#AddModule mod_php4.c" and uncomment it. (Remove the "#" from that line.)
    6. Save the file.
  3. Restart the Apache web server
    1. Bring up System Preferences. It is available under the Apple menu.
    2. Click on Sharing
    3. Uncheck "Personal Web Sharing" On the right, it will say "Personal Web Sharing On". The message below will disappear. If you try visiting the links in Safari, you will get an error message.
    4. Check "Personal Web Sharing" again. On the right, it should say "Personal Web Sharing On"
    5. You should see a message below saying "View this computer's web site at [first link] or your personal website at [second link].
    6. Click on [first link]. Safari should come up with the Apache logo and a message saying the installation of the Apache web server was successful.
    7. Go back to System Preferences and click on [second link]. Safari should come forward with a big "X Your website here."
  4. Create a test.php file
    1. In the terminal window, cd to ~/Sites. You should see index.html there. This is the file that shows "X Your website here"
    2. In the same directory, create a file named test.php. The file should contain a single line as follows: <?php phpinfo(); ?>
    3. Visit [second link] in Safari, but add "test.php" to the end.
    4. You should see a nice big table containing lots of information about PHP. The PHP logo and PHP version will be visible at the top.

Tags: Technical

Created at: 9 May 2009 11:05 AM

NO COMMENTS ALLOWED