Enabling the built-in PHP support in 10.2

Jan 24, '03 08:42:36AM

Contributed by: quinnmacdonald

How to enable PHP and configure default index documents to serve index.php. Watch out for quotes. Login in as an Administrator to do this. Enter your password when needed.

  1. Enabling PHP under Mac OS X 10.2. These commands enable php and restart Apache in the Terminal:
     % cd /etc/httpd
    % sudo apxs -e -a -n php4 libexec/httpd/libphp4.so
    % echo 'echo "AddType application/x-httpd-php .php"
    >> /etc/httpd/httpd.conf' | sudo sh -s
    % sudo apachectl graceful
    [editor's note: The line with the backslash is one long line -- if you're hand-typing, remove the backslash and leave a space.]

    PHP should now be running.

  2. Enabling Index.php in the Default Index Documents config. These Terminal commands enable Apache to serve index.php in addition to index.html:
     % pico /etc/httpd/httpd.conf
    Look for "DirectoryIndex index.html" and change it to "DirectoryIndex index.html index.php". Save your changes (use the on-screen prompts) and restart Apache by typing sudo apachectl graceful.

  3. Testing PHP A quick test to see if everything works. Create a generic index.php file that prints the PHP info (either google it or download and unzip this one) and save it in your /Library -> WebServer directory. Now open 127.0.0.1/ in your web browser. You should see a status table with information about the PHP module.
Ta da!

[Editor's note: I have not tested this hint, as my PHP remained enabled through the 10.2 update. Please post if you notice any errors (more than likely due to my editing work!). There are also other hints here on installing PHP and MySQL, but none that specifically address enabling the built-in PHP support in 10.2.]

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030124054236237