1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Enabling PHP on Mac OS 10.6

Discussion in 'Web Design & Development' started by andynic, Apr 24, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. andynic

    andynic Thread Starter

    Joined:
    May 25, 2007
    Messages:
    299
    Hi,

    I am totally new to PHP.

    Am developing on Mac OS X 10.6.7, Apache Server 2.2.17, MySQL 5.1.39.
    All of the above works fine when I develop web pages using Perl CGI with Perl DBI.

    I am now trying to learn PHP and am having difficulty getting the first test script to run.

    Rather than installing MAMP as recommended in Robin Nixon's book (O'Reilly) on the subject,
    I'd like to just enable PHP 5 which is dielivered with the Mac OS X.

    To that end I have followed the instructions at http://maestric.com/doc/mac/apache_php_mysql_snow_leopard
    (which I found referenced on the Apple Support Forums).

    The simple test script that I am trying to run is shown at the end of this post (file a.php):

    If I put the URL address file:///Users/andynic/a.php in Safari, rather then putting up "Welcom to PHP First Test"
    it puts up the code you see above.

    Any idea about what I have done wrong?

    Thanks for your help.
    Andynic

    File a.php:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhml1-strict.dtd">

    <?php
    $name = "First Test"; // declaration
    ?>

    <html>
    <head>
    <title>Test PHP</title>
    </head>
    <body style='font-family:Arial; font-size:18px;'>
    Welcome to PHP, <?php print( "$name" ); ?>
    </body>
    </html>
     
  2. andynic

    andynic Thread Starter

    Joined:
    May 25, 2007
    Messages:
    299
    Additional information:

    If I enter this in the Safari URL address field:
    http://localhost/gfrmDevBin/a.php
    where "gfrmDevBin" is a location defined in the httpd.conf file, I get:
    Internal Server Error

    The error in the Apache error_log file is:
    Premature end of script headers: a.php
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/993133