php not working with 'localhost'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MikeDub

    php not working with 'localhost'

    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:
    (http://192.130.0.230/~username/file.php) works
    (http://localhost/~username/file.php) does not work.

    oh.. I'm using a MAMP setup

    ~mike (new to this group)

  • clashers5@gmail.com

    #2
    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
    already
    added this for you, but be sure to check.

    For PHP 4:

    LoadModule php4_module modules/libphp4.so

    For PHP 5:

    LoadModule php5_module modules/libphp5.so

    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
    PHP
    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

    On Jul 2, 10:49 am, MikeDub <mworthi...@gma il.comwrote:
    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:
    (http://192.130.0.230/~username/file.php) works
    (http://localhost/~username/file.php) does not work.
    >
    oh.. I'm using a MAMP setup
    >
    ~mike (new to this group)

    Comment

    • Jerry Stuckle

      #3
      Re: php not working with 'localhost'

      MikeDub wrote:
      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:
      (http://192.130.0.230/~username/file.php) works
      (http://localhost/~username/file.php) does not work.
      >
      oh.. I'm using a MAMP setup
      >
      ~mike (new to this group)
      >
      I agree this looks like an Apache configuration problem. Try
      alt.apache.conf iguration.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      Working...