How to activate PHP in Mac OS

Leopard:

  • Startup Terminal, and run the following commands:
    1. $> cd /etc/apache2/
      $> sudo pico httpd.conf
      [Enter]
      press [CTRL]+[W]
      type: php [Enter]
  • You should see the following line:
    1. # LoadModule php5_module libexec/apache2/libphp5.so
      Now remove the hash (#)
    Thats it, now save the file:
    press [CTRL]+[O], [Enter]

    To exit Pico, press [Ctrl]+[X]

    To activate PHP, reboot or enter in terminal:
    $> sudo apachectl restart

    Tiger:

  • Startup Terminal, and run the following commands:
    1. $> cd /etc/httpd
      $> sudo pico httpd.conf
      [Enter]
      press [CTRL]+[W]
      type: php [Enter]
  • You should see the following line:
    1. # LoadModule php4_module libexec/httpd/libphp4.so
      Now remove the hash (#)
      Repeat the same procedure until you find this line:
      # AddModule mod_php4.c
      And remove the hash (#).
    Thats it, now save the file:
    press [CTRL]+[O], [Enter]

    To exit Pico, press [Ctrl]+[X]

    To activate PHP, reboot or enter in terminal:
    $> sudo apachectl restart

    Comments (7)  Permalink

    Comments

    sffc @ 29.05.2007 22:29 CET
    There's another easy way to access httpd.conf. In Safari, go to this address:

    file:///private/etc/httpd/httpd.conf

    Open the file in Text Edit, and follow the above procedure, and save the file as you normally would.
    Cristiano Betta @ 08.01.2008 18:07 CET
    Thanx for setting up a quick cheatsheet.
    Paulo Resende @ 21.01.2008 12:26 CET
    My system is the leopard but i don´t have the httpd.conf in my system!!
    Lyoness @ 18.03.2008 19:01 CET
    That worked great! Thanks for this!
    Robert Wilde @ 26.08.2008 05:16 CET
    You don't know how long I have been searching for the php activation for my Intel iMac. It's as if Apple never heard of such a thing! I write my own website code and couldn't test it out ... frustrating! You could tell Paulo Resende (21-01-2008) that I had to re-enter the commands a number of times before I actually got into the Apache directory. The $> entries were confusing me until I realized I didn't have to type them in.
    wicus @ 09.09.2008 14:00 CET
    [ Error writing httpd.conf: Permission denied ] I need the manual on verify and repair disk permissions.
    Jurij Burkanov @ 26.10.2008 21:46 CET
    Hey, thanks a lot! You saved my evening :)

    add a comment

    This blog is gravatar enabled.
    Your email adress will never be published.
    Comment spam will be deleted!

    Name*
    E-Mail
    For Spammers Only
    URL
    Comment*
    Notify me via E-Mail when new comments are made to this entry
    Remember me (needs cookies)