For non nerds or starters like me:
To enable PHP and Apache in Leopard:
Apache is simple, go to the sharing panel in system
preferences, and enable “Web Sharing”.
PHP requires he use of Terminal (or a BBEdit/Textwrangler if
you prefer).
First check you have enabled Root in Leopard.
If not here’s how:
1. Open the Directory Utility: In the Finder, navigate to
the Utilities folder (tip: click on the desktop, hit Cmd+Shift+U).
2. Click on the padlock to allow edits.
3. Go Edit > Enable Root Password
4. Enter and re-enter your password.
Now, you are set to access protected areas of the system via
the terminal. Probably a good idea to back up any file before you
modify it, just in case.
Back to terminal...
when you first start terminal it will show your Admin name
followed by a colon,
eg johnsmith:
type “su” the press enter
terminal will the ask for a password,
type in your “password” and press enter.
Note your password doesn’t appear on the screen.
You have two files to alter briefly.
First file:
Type: sudo pico /private/etc/apache2/httpd.conf
and press enter (note the space after sudo and pico).
This opens the file: htpd.conf a hidden file.
Now if you haven’t used this before (I hadn’t and
learned on the job), the navigation symbols at the screen bottom
with an inverted “v” and a letter , mean to press
control and the letter, for example “control X” to
exit.
You need to alter 3 lines of code:
1....Use the arrow keys to move down the page...first find a
group of coded lines that start with:
LoadModule (there are many lines)..
near the end you’ll find a line:
#LoadModule php5_module modules/libphp5.so
you need to remove the “#” to uncomment and make
it active. Position the cursor to the right of the hash and press
delete.
2....Next find a line starting with
“DirectoryIndex” it probably looks like:
DirectoryIndex index.html
Alter it to this:
DirectoryIndex index.html index.html.var index.php
3....Next find a group of lines that have “ AddType
application/x ........”
I seem to remember there were 2 lines like that,
add a line straight after like this:
AddType application/x-httpd-php .php ( note the space between
php and .php)
To save your file press “control X” to exit, and
“Y” (yes) to save. It then asks if you want to save as
a name/different, I just pressed enter to accept the default name.
I went back to check all had been saved by re-opening the
file.
Second File:
Type: sudo pico /private/etc/php.ini.default
You only need to alter one line n this file.
Look for a series of lines beginning with a semi-colon like
this:
;error_reporting = etc etc etc
Find a line below without a semi colon like this:
error_reporting = E_ALL & -E_NOTICE
then edit out all after “E_ALL” so it looks like
this:
error_reporting = E_ALL
Save you work as before.
You can now test PHP works quickly by starting TextEdit and
type in:
<?php
phpinfo();
?>
Save the file as “test.php” to your root web
directory
on my Mac is” Macintosh HD/Library/WebServer/Documents
(Actually I also saved it to just the WebServer folder).
Start up your browser and enter a URL:
http://localhost/test.php
If all has been done as above you’ll get a ful listing
of php stuff you probably don’t need to know!