apache无法运行任何php

时间:2016-05-06 21:48:39

标签: php apache

我已经在我的覆盆子pi上安装了一个apache服务器,除非我尝试提供php,否则一切似乎都运行正常。

/var/www/html/index.html serves fine
/var/www/html/foo/index/index.html serves fines

但如果我添加index.php,那就说:

<?php echo "hello world"; ?>

我通过访问/ var / www / html获得 403 -Forbbiden ,但我仍然可以访问/var/www/html/foo/index.html(DirectoryIndex设置为.php .html .htm )。

如果我运行$php index.php:hello world

所以,它可以提供.html,它可以运行.php,但它无法提供.php。

我该如何解决这个问题?我找到了很多解决方案,但没有一个适合我。

注意: 我从局域网访问站点。 Server OS(uname -a):Linux raspbian-AH 4.1.19-v7 +#858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU / Linux

如评论中所述,我们可以很容易地推断模块未加载但我在这里是:

pi@raspbian-AH:/etc/apache2/mods-available $ cat php5.conf 
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
    Require all denied
</FilesMatch>

# Running PHP scripts in user directories is disabled by default
# 
# 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_flag engine Off
    </Directory>
</IfModule>

和php5.load:

pi@raspbian-AH:/etc/apache2/mods-available $ cat php5.load
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

1 个答案:

答案 0 :(得分:0)

感谢dan08,我发现我的设置搞砸了某种方式。因此,我没有查明问题,而是清除了所有内容并重新安装。无论如何都没有什么可以保存的。

所以解决方案是:

sudo apt-get purge apache2 php5 libapache2-mod-php5
sudo apt-get install apache2 php5 libapache2-mod-php5