Results 1 to 5 of 5

Thread: Enabling PHP

  1. #1


    Member Since
    Mar 10, 2009
    Posts
    5
    Enabling PHP
    I can't seem to get php to work.

    I was following a tutorial for php when I opened this file in my browser (called index.php):

    Code:
    <html>
     <head>
      <title>PHP Test</title>
     </head>
     <body>
     <?php echo "<p>Hello World!</p>"; ?> 
     </body>
    </html>
    It either displays all of the text in the file, or:
    Code:
    Hello World!
    ; ?>
    I googled mac tutorials for php, and found that it needed to be enabled, so I followed the instructions, took out the comment in the /private/etc/apache2/httpd.conf file, but it still doesn't seem to work.

    So basically I'm lost.

    What am I doing wrong? I'm sure it's something really simple...

  2. #2

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    Simple instructions:
    1. Turn on Web Sharing in System Preferences
    2. Open /Applications/Utilities/Terminal.app
    3. Execute the following in the Terminal: sudo nano /private/etc/apache2/httpd.conf
    4. Scroll down to the following line: LoadModule php5_module libexec/apache2/libphp5.so (second last LoadModule line for me)
    5. Uncomment it by removing the # at the beginning
    6. Save that by pushing CTRL-O and then exit by pushing CTRL-X
    7. Type the follwing command: sudo apachectl restart
    8. Enjoy php

    Let me know if you encounter any problems.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  3. #3


    Member Since
    Mar 10, 2009
    Posts
    5
    I did all of that except the "sudo apachectl restart" part - could that really be the only problem?

  4. #4


    Member Since
    Mar 10, 2009
    Posts
    5
    It seems to be working. All I had to do was run sudo apachectl restart.

    Thanks a lot!

  5. #5

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    Quote Originally Posted by InkL0sed View Post
    I did all of that except the "sudo apachectl restart" part - could that really be the only problem?
    In case you're still wondering, yes that's the culprit. If you make changes to apache's config file (and many other programs), you have to restart them for the changes to take effect.

    Best of luck with PHP!
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. enabling PHP on leopard - problems
    By osbourne.cox in forum OS X - Development and Darwin
    Replies: 3
    Last Post: 12-27-2010, 03:42 PM
  2. Enabling PHP
    By Rogan in forum OS X - Operating System
    Replies: 0
    Last Post: 02-21-2010, 07:37 AM
  3. Setting up PHP and PHP Nuke
    By EvoMac in forum Web Design and Hosting
    Replies: 2
    Last Post: 02-18-2005, 12:38 PM
  4. Enabling PHP
    By JGarcia in forum Web Design and Hosting
    Replies: 3
    Last Post: 03-05-2004, 09:35 PM
  5. Enabling PHP in Mac OS 10.2
    By dmonk in forum OS X - Development and Darwin
    Replies: 4
    Last Post: 01-11-2004, 09:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •