Who knows how many others are out there like me who are relatively new to this (configuring your Mac); and I might even have to use this tutorial myself some day if I forget...
So in this 22-step-tutorial I will (literally) show you how to enable PHP and SSI on Leopard (or Snow Leopard, if you have that) — not the server version — and how to set the localhost root to your own "Sites" directory as well as making sure you get all PHP error messages for debugging purposes. It should be pretty fool-proof, because that's how I tried to make it
Here is the color legend so you can quickly identify important elements in each step:
FILE to be opened or run
STRING to be found or input
COMMAND to be run in Terminal
Now... hopefully the first few screenshots have loaded by now
1. The first step is to locate this file: /private/etc/apache2/httpd.conf and open it in a text editor like TextMate. The editor will need to be able to open hidden system files!

2. Then search for the following string: LoadModule php5_module
It should be on line 114 and have a hash (#) symbol in front of it. (The whole line reads "#LoadModule php5_module libexec/apache2/libphp5.so")
(Screenshot)
3. Remove the hash from the beginning of the line. (If there isn't one, ignore this step.)
(Screenshot)
4. Now find this next string in the document: DocumentRoot
(The instance we want here should look like this.)
5. Change the stuff between the quotes to the path to your "Sites" folders (starting from the top with a forward slash (/)).
Use your short-name, not the name that you see when logging into OS X (unless it is the same). For me it looks like this.
6. Now find the second instance of: <Directory
You should see this.)
7. Change the path there to the same one as from step 5.
(For me it's this.)
8. Now scroll down just a bit; to the 203rd line. It should look like this:

9. Add " Includes" to the end of that line.
(Screenshot)
10. Next up, search the file for the following string: #AddType text
It should bring you to these couple of lines:

11. Remove the two hash symbols as such:

12. Let's save the file now. You will probably have to confirm the changes by entering your password.
(In TextMate, this little window pops up.)
Now we've enabled PHP, set the localhost root to our "Sites" folder and generally enabled SSI.
But we're not done yet!
13. Open this file next: /private/etc/apache2/users/USERNAME.conf
Obviously you need to replace "USERNAME" with your own short-version name of your Mac when looking!
(Screenshot)
The file should look like this:

14. Add the " Includes" option as it is in this screenshot:

15. Okay, save the file (and confirm the changes if it requires you to).
Now we've got SSI working!!
The last part of this tutorial will show you how to make all PHP error messages show up when they occur.
16. Open Terminal (/Applications/Utilities/Terminal.app), type or paste the following command and hit enter: cd /private/etc
(Screenshot)
17. Now this command: sudo cp php.ini.default php.ini
(Screenshot)
You will probably be prompted for your admin password like this:

18. Don't panic if you don't see the little stars which usually indicate a password; just keep on typing and make sure it is correct!
Done? Good. Now that we have copied a certain "php.ini.default" file with Terminal, we're going to edit it briefly!
19. So, open the just copied file in your most beloved text editor again: /private/etc/php.ini

20. Drive down to 305 (514 on Snow Leopard) and make sure you're seeing the same bit as in this screenshot:
(On Snow Leopard the part that is underlined in green will read "& ~E_DEPRECATED" and not "& ~E_NOTICE".)

21. Remove the " & ~E_NOTICE" (or the "& ~E_DEPRECATED") as done here:

22. Good, save the file and open the system preferences.
If "Web Sharing" in the Sharing panel isn't checked yet, check it. If it already is, uncheck it and check it again.
(Screenshot)
You might have to run the following command in Terminal if the previous step didn't work for you: sudo apachectl graceful
(Screenshot)
If everything went well you should now be able to test PHP files and use SSI commands, all within your own "Sites" directory
Now you may also be interested in a quick walkthrough I made, explaining how to allow PHP to write files, since that will not be possible by default.
I hope you liked the tutorial and that it was useful to you!
I originally wanted to have all the screenshots inline but then I realized there is a limit as to how many pictures can be in a post
Finally, here are all the web-resources I used to construct the tutorial (they get a lot of credit since this tutorial is basically a merger of all of these):
- How to run PHP on OS X within the Sites directory (thanks Marc)
- Enabling PHP and Apache in Leopard
- Leopard & Apache SSI
- SSI not working - Apache under Windows
- SSI (server side include) on 10.5 (client)
This post has been edited by temhawk: 10 December 2010 - 09:01 AM


Help

MultiQuote











