PHP文件已下载,未加载

时间:2012-01-12 03:28:19

标签: php html

我有以下php文件:

<html>
<body>
<?php

echo "test";

?>

</body>
</html>

我的httpd.conf文件包含以下条目:

grep php /var/apache/conf/httpd.conf
LoadModule php5_module        modules/libphp5.so

为什么文件总是被下载而不是在浏览器中加载?

1 个答案:

答案 0 :(得分:2)

您还需要为.php文件设置正确的内容处理程序/ MIME类型。默认的Ubuntu php配置包含: -

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
    SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    <IfModule mod_userdir.c>
        <Directory /home/*/public_html>
            php_admin_value engine Off
        </Directory>
    </IfModule>
</IfModule>