Link to home
Start Free TrialLog in
Avatar of harlow
harlow

asked on

PHP Apache 2 Mac OS X

This is probably really simple, but I can't find a targeted answer in the archives.  I am a neophyte on running a web server, but I have Apache 2, PHP 5, MySQL, etc running happily on MacOS X 10.3.9.  Here is the problem.  If I embed a PHP script in an HTML document like so:

<HTML>
<HEAD>
</HEAD>
<BODY>
This is html
<?php
print ("This is php\n");
?>
</BODY>
</HTML>

the server does not seem to understand the script; it just sends out the php source text as if it were part of the html.  In my httpd.conf, I have the following statements:

LoadModule php5_module        modules/libphp5.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.php

I can't figure out what is missing here.  If  I just browse a file foo.php with a php script in it, it works happily, but the same script embedded in html does not work. Anyone got any ideas?
Thanks

JEH
ASKER CERTIFIED SOLUTION
Avatar of ThomasFranke
ThomasFranke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of harlow
harlow

ASKER

I have been following the text and examples in "PHP for the World Wide Web" by Larry Ullman, Peachpit Press, 2001. Here is a very simple example script that he gives in the boook; its name is script_1_3.php:

<HTML>
<HEAD>
<TITLE>First PHP Script</TITLE>
</HEAD>
<BODY>
<?PHP
print ("Hello, world!");
?>
</BODY>
</HTML>

You are right on the money: I was using a .html extension on this kind of file.  When I make it .php, it works fine.

Thanks!

JEH
Glad it works ;-)

Have fun coding