0

So I was working with MAMP on my Macbook Pro (running OS X 10.10) and it was working fine, but now MAMP wont process PHP at all.

I have a file named 'index.php' in /MAMP/htdocs/

It contains only one line (minus the first space before the opening ?):

< ?php echo "hello"; ?>

MAMP runs just fine, but when I load the file it just outputs the code directly

http://imgur.com/a/Ay6km#1

If I include some simple HTML in the index.php, like this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <?php echo "hello"; ?>
</body>
</html>

Then it simply adds the PHP line as a comment to the file.

http://imgur.com/a/Ay6km#2

I made sure to uncomment the LoadModule line in the /private/etc/apache2/httpd.conf file. I had to add the AddModule line because it wasn't anywhere in the file.

I've reinstalled MAMP with no difference. MAMP is running PHP v5.5.14, cache is turned off.

I've tried just using a simple Apache server (after stopping MAMP and restarting) by running sudo apachectl start, and I don't get any errors in Terminal, but when I try to load http://localhost the webpage is not found.

Anyone have any advice? Is there a place I can check for errors?

edit: a copy of my httpd file has been added to the comments

3

1 Answer 1

1

The PHP documentation says that httpd.conf should have the following lines:

<IfModule mod_php5.c>
    # If php is turned on, we respect .php and .phps files.
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    # Since most users will want index.php to work we
    # also automatically enable index.php
    <IfModule mod_dir.c>
        DirectoryIndex index.html index.php
    </IfModule>
</IfModule>

This block is missing from your file.

Check the other steps at the above documentation link as well.

3
  • Hey Barmar, I followed all those steps and no luck. MAMP still does not process PHP and I still cannot load the default apache server via localhost (without MAMP).
    – Aweary
    Sep 13, 2014 at 18:10
  • I wonder if you're editing the correct httpd.conf. WHen I google this, it says it's in /Applications/MAMP/conf/apache/httpd.conf. I think the one in /etc is the file for the native OS X webserver, not MAMP.
    – Barmar
    Sep 13, 2014 at 19:19
  • You're exactly right, I was editing the native httpd file. ill try that ASAP. I'm actually having some issues getting the native apache server to start too. I posted it as a separate issue here, if you can take a look: stackoverflow.com/questions/25826362/…
    – Aweary
    Sep 13, 2014 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.