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.
[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.]
- Enabling PHP under Mac OS X 10.2. These commands enable php and restart Apache in the Terminal:
% cd /etc/httpd
[editor's note: The line with the backslash is one long line -- if you're hand-typing, remove the backslash and leave a space.]
% 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
PHP should now be running.
- 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.
- 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.
[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.]
•
[18,495 views]

