2016-05-06 3 views
0

Ich habe einen Apache-Server auf meinem Raspberry Pi installiert und alles scheint gut zu laufen, es sei denn, ich versuche, PHP zu dienen.Apache kann kein PHP laufen

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

Aber wenn ich index.php hinzufügen, sagen wir mal:

<?php echo "hello world"; ?> 

I 403 -Forbbiden erhalten durch den Zugriff auf/var/www/html, aber ich kann immer noch Zugriff auf/var/www/html/foo/index.html (DirectoryIndex auf .php .html .htm gesetzt).

Und wenn ich $php index.php laufen: Hallo Welt

So kann es .html nicht dient, kann er laufen .php, aber es kann nicht dazu dienen, .php.

Wie kann ich das beheben? Ich fand viele Lösungen, aber keine funktionierte für mich.

Hinweis: Ich greife auf die Standorte aus dem LAN. Server OS (uname -a): Linux Raspbian-AH 4.1.19-v7 + # 858 SMP Di 15. März 15:56:00 GMT 2016 armv7l GNU/Linux

Wie in den Kommentaren angegeben, könnten wir einfach Modul ableiten hier nicht geladen ist, aber ich es ist:

[email protected]:/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> 

und die php5.load:

[email protected]:/etc/apache2/mods-available $ cat php5.load 
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so 
+0

Klingt wie Sie nicht das PHP-Modul zu 'httpd.conf' Datei hinzugefügt haben. – Jhecht

+0

Diese Datei existiert nicht in meinem Dateisystem (Test mit Find), aber ich nehme an /etc/apache2/apache2.conf ist der Name für meinen? –

+0

Welche bestimmte Linux-Distribution verwenden Sie? – Jhecht

Antwort

0

Dank dan08, fand ich mein Set up out wurde vermasselt ist eine Möglichkeit. Anstatt das Problem zu lokalisieren, habe ich alles gelöscht und neu installiert. Es gab sowieso nichts zu retten.

So war die Lösung:

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