php not working with 'localhost'

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
When I run a php file in my browser using an IP address, it renders
just fine. But when I run the php file using 'localhost', it renders
the source code. It's as if it does not recognize it as php. There are
other variables, but I don't want to make a full page post.

In a nutshell:
( ) works
(http://localhost/~username/file.php) does not work.

oh.. I'm using a MAMP setup

~mike (new to this group)

Re: php not working with 'localhost'

Sounds like an apache configuration issue. The following is an excerpt
from the INSTALL file that comes with the php distribution:

14. Edit your httpd.conf to load the PHP module.  The path on the
right hand
    side of the LoadModule statement must point to the path of the PHP
    module on your system.  The make install from above may have
    added this for you, but be sure to check.

    For PHP 4:

      LoadModule php4_module modules/

    For PHP 5:

      LoadModule php5_module modules/

15. Tell Apache to parse certain extensions as PHP.  For example,
    let's have Apache parse the .php extension as PHP.  You could
    have any extension(s) parse as PHP by simply adding more, with
    each separated by a space.  We'll add .phtml to demonstrate.

      AddType application/x-httpd-php .php .phtml

    It's also common to setup the .phps extension to show highlighted
    source, this can be done with:

      AddType application/x-httpd-php-source .phps

Make sure that you have done this in your apache configuration file
such that apache knows that any requests for localhost handle .php
files with the php module.

That is not particularly helpful, but I hope it at least points you in
the right direction

Quoted text here. Click to load it

Re: php not working with 'localhost'

MikeDub wrote:
Quoted text here. Click to load it

I agree this looks like an Apache configuration problem.  Try  

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline