duan39779 2014-09-13 01:57
浏览 83

MAMP不处理PHP

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

  • 写回答

1条回答 默认 最新

  • dpka7974 2014-09-13 02:22
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题