Enable PHP on mac OS X 10.4.10

Posted on 2007-08-01
Last Modified: 2013-12-13
I am trying to enable PHP on my OS X 10.4.10.   I have been working with PHP on a hosted site but will be traveling and need to install it locally (with mySQL) so that I can work on the plane.  I found articles online which say to modify:
by un-commenting the two lines and then restarting apache:
    LoadModule php4_module libexec/httpd/
    AddModule mod_php4.c
I have done this and verified that these lines are no longer commented out.  I guess because of the version, my httpd.conf file already has the following relevant entries:
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    <IfModule mod_dir.c>
       DirectoryIndex index.html index.php index.htm
It seems this couldn't be easier but when I open local php files in a browser, I see the php code instead of the interpereted info.  I tried a default <?php phpinfo(); ?> and also opened a larger php file that I have been working with on my hosted server but the browser just displays the raw php code.  I have restarted my computer and scowered the web but have found surprisingly little about this issue.  I'd prefer not to install a new version of PHP as it should be unnecessary and I'm afraid it will lead to more challenges (the version of php doesn't matter, I'm not doing anything fancy with my code).  I have also visited my default local web site and I get the apache splash page saying that it is running.
Any help you can provide is greatly appreciated.
Question by:tolmang
    LVL 39

    Expert Comment

    Did you Switch OFF Internet Sharing in the System Preferences, Sharing Panel  and then RE-enable it as you need to restart Apache to enable PHP or reboot the Mac to activate PHP ??

    Author Comment

    Yes, I restarted Apache by turning Internet Sharing off and then back on.  I also did it from the command line:
     sudo /usr/sbin/apachectl stop
     sudo /usr/sbin/apachectl start
    And again by restarting the computer.  Each time I looked at the Apache splash page to ensure it was running before testing PHP.
    Do I need to start PHP itself or do something more than modifying the httpd.conf file as described above?
    LVL 39

    Accepted Solution

    You've done everyting right .. it should work ..
    The quickest solution rather than wasting too much time

    1. Download the Entrpy PHP installer
    It is really easy and fast and will set itself up

    2. Try using MAMP - my preferred option
    This is a seperate installation of Apache2, MySQL and PHP which sits in your Applications folder and works first time every time!!
    You just drop your code into the htdocs folder inside the MAMP folder and away you go!!


    Author Comment

    I tried MAMP but it is not working eiither.  I couldn't download it from their site (broken links) but I downloaded it from (listed as release 1.6).  It seemed to install fine.  I used the widget to start the servers and moved my test files in to the applications/MAMP/htdocs directory.  Still, when I open the file with Safari, it displays:
    The widget shows the servers are running.  I rebooted to see if it would make any difference.  I also put one of my large php files in this dir but as with the test file, Safari displays the raw code.
    Any other ideas?

    Author Comment

    The Apache log looks fine (most recent entry):
    [Wed Aug 01 19:09:12 2007] [notice] Digest: generating secret for digest authentication ...
    [Wed Aug 01 19:09:12 2007] [notice] Digest: done
    [Wed Aug 01 19:09:13 2007] [notice] Apache/2.0.59 (Unix) PHP/5.2.1 DAV/2 mod_ssl/2.0.59 OpenSSL/0.9.7l configured -- resuming normal operations

    Author Comment

    So it is working after all (no surprise).  I didn't know that I needed to open the files a special way, using the ports, etc.  The files now display correctly in Safari when (instead of just opening the file), I put the following in the address bar:
    The file phpinfo.php is in the directory:

    Thanks for your help.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now