PHP is a fabulous scripting language for beginners to try their hands at serving up dynamic web content.
Much like server-side includes [Hack #94], PHP code is included and interpreted into the actual HTML of your web pages. Here, we’ll show you how to turn it on (it’s installed by default on OS X), as well as how to certify that it’s working properly.
As with the hacks on CGI and SSI, turning on PHP involves searching
for the feature name (in this case,
the Apache configuration file
[Hack #89]. The first
entries we’ll run into are:
# LoadModule php4_module libexec/httpd/libphp4.so ... # AddModule mod_php4.c
These two lines enable (or disable, if commented out with a
#) the loading of PHP on Apache web-server
startup. Since they’re commented out by default,
we’ll have to uncomment them in order to have the
modules loaded and PHP functional. Do so, and the lines should now
look like this:
LoadModule php4_module libexec/httpd/libphp4.so...
Keep searching for
php in the file and
# For example, the PHP 3.x module will typically use: # # AddType application/x-httpd-php3 .php3 # AddType application/x-httpd-php3-source .phps # # And for PHP 4.x, use: # # AddType application/x-httpd-php .php # AddType application/x-httpd-php-source .phps
In some OS X installations (notably, 10.2 and higher), you won’t see the preceding lines. That’s alright; just add them in yourself.
In essence, these lines are saying that any file with ...