Jump to content

Enabling PHP and SSI in Leopard, tutorial

works for Snow Leopard

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Enabling PHP and SSI in Leopard, tutorial works for Snow Leopard Rate Topic: -----

Poll: Rate this tutorial please. (6 member(s) have cast votes)

Did this tutorial help you? If you are just interested in this tutorial without actually using it, does it seem good to you anyway?

  1. Yes, very much ++ (4 votes [66.67%])

    Percentage of vote: 66.67%

  2. Yep + (1 votes [16.67%])

    Percentage of vote: 16.67%

  3. Not sure (0 votes [0.00%])

    Percentage of vote: 0.00%

  4. Nope - (1 votes [16.67%])

    Percentage of vote: 16.67%

  5. No, not at all -- (0 votes [0.00%])

    Percentage of vote: 0.00%

Vote Guests cannot vote

#1 User is offline   temhawk 

  • W.R. Private First-Class
  • Group: Members
  • Posts: 322
  • Joined: 30-August 07
  • Gender:Male
  • Interests:travel, cg art, macs, music, skateboarding, programming, discovery channel, TextMate 2

Posted 25 November 2008 - 11:11 AM

Hello, I needed to set up my new Mac for web development and I thought I would record all the steps with screenshots while I was at it :)

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 :P

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!
Posted Image
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:
Posted Image
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:
Posted Image
11. Remove the two hash symbols as such:
Posted Image
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:
Posted Image
14. Add the " Includes" option as it is in this screenshot:
Posted Image
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:
Posted Image
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
Posted Image
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".)
Posted Image
21. Remove the " & ~E_NOTICE" (or the "& ~E_DEPRECATED") as done here:
Posted Image
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 :rolleyes:

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):

This post has been edited by temhawk: 10 December 2010 - 09:01 AM

0

#2 User is offline   sypher 

  • the owner3r
  • Group: Administrators
  • Posts: 1,578
  • Joined: 04-April 06
  • Location:North Wales, UK
  • Interests:Art, Boxing, MMA, Graphic Design, Web Design etc. ;)

Posted 25 November 2008 - 12:22 PM

Great work hawk :D
sypher design - North Wales Web Design | Latest Work: - Scala Cinema

CSS - Can't See Sh*t
0

#3 User is offline   temhawk 

  • W.R. Private First-Class
  • Group: Members
  • Posts: 322
  • Joined: 30-August 07
  • Gender:Male
  • Interests:travel, cg art, macs, music, skateboarding, programming, discovery channel, TextMate 2

Posted 25 November 2008 - 12:26 PM

Thanks :D

I really did my best to make this a tutorial that even I would understand ^_^

This post has been edited by temhawk: 19 December 2009 - 08:48 PM

0

#4 User is offline   marcamos 

  • W.R. General
  • Group: Administrators
  • Posts: 2,849
  • Joined: 04-April 06
  • Gender:Male
  • Location:Massachusetts - USA

Posted 25 November 2008 - 08:24 PM

Wow - I haven't read it all, but that's a lot of effort you put in; thanks!
0

#5 User is offline   Rodney Pruitt 

  • W.R. Private
  • Group: Members
  • Posts: 4
  • Joined: 17-December 08

Posted 17 December 2008 - 08:40 PM

Thanks! FINALLY! An up to date and easy to follow guide to making this work. Followed a patchwork of instructions before this to no avail. luckily I saved a back-up of my httpd.conf file. So this worked like a charm!
0

#6 User is offline   temhawk 

  • W.R. Private First-Class
  • Group: Members
  • Posts: 322
  • Joined: 30-August 07
  • Gender:Male
  • Interests:travel, cg art, macs, music, skateboarding, programming, discovery channel, TextMate 2

Posted 18 December 2008 - 08:18 AM

View PostRodney Pruitt, on Dec 18 2008, 02:40 AM, said:

Thanks! FINALLY! An up to date and easy to follow guide to making this work. Followed a patchwork of instructions before this to no avail. luckily I saved a back-up of my httpd.conf file. So this worked like a charm!

Thank you for your feedback, I'm very happy I could help ^_^

This post has been edited by temhawk: 19 December 2009 - 08:48 PM

0

#7 User is offline   Ann Ames 

  • W.R. Private
  • Group: Members
  • Posts: 1
  • Joined: 14-January 09

Posted 14 January 2009 - 11:20 PM

Wow, you have saved me a lot of pain and frustration! Thanks a million for a very thorough job.
0

#8 User is offline   Joe Develper 

  • W.R. Corporal
  • Group: Members
  • Posts: 50
  • Joined: 07-December 10
  • Gender:Male
  • Interests:Web development, Internet Surfing etc.

Posted 10 December 2010 - 06:45 AM

wow! very nice. Goo job, keep it up.
0

#9 User is offline   temhawk 

  • W.R. Private First-Class
  • Group: Members
  • Posts: 322
  • Joined: 30-August 07
  • Gender:Male
  • Interests:travel, cg art, macs, music, skateboarding, programming, discovery channel, TextMate 2

Posted 10 December 2010 - 09:00 AM

Thank you for your praise. I just realized, however, that I can't count. It's not 20 steps, it's 22 :blushing:
0

#10 User is offline   JakeMcGreg 

  • W.R. Private
  • Group: Members
  • Posts: 46
  • Joined: 15-December 10

Posted 18 January 2011 - 12:48 AM

Glad you noticed that but over all keep up the good job. Nice one :)
Website Design Packages - CMS Website, SEO Tools & a personalised 12 month strategy guide
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users