0
votes

it is my first question here. I get 403 - Forbidden for every php file. Tried with index.php and other names like test.php. Tried different subfolders and in /var/www/html directly.

Raspberry Pi 2 Model B Rev 1.1    
Server version: Apache/2.4.10 (Raspbian)
Server built:   Jul 18 2017 22:21:17

All updates installed. Have owncloud, pihole, mysql installed. It worked fine and after a restart it stopped working and more restarts don't fix it. Had to fix some network issues with 'no route to host' and a new external HDD.

I set permissions with

sudo find /var/www -type d -exec chmod 755 {} +
sudo find /var/www -type f -exec chmod 644 {} +

so folders are 755 and files are 644. Owner is also www-data:www-data everywhere in /var/www

so th structure to my index.php example would be

drwxr-xr-x  12 root root  4096 May  4 05:01 var    
drwxr-xr-x  4 root root       4096 Jul 25 20:47 www
drwxr-xr-x  6 www-data www-data 4096 Jul 25 19:52 html
-rw-r--r--  1 www-data www-data    29 Jul 24 20:08 index.php

also tried chmod 777 on index.php but still 403 error.

index.php:

<?php echo "hello world"; ?>

or

<?php phpinfo(); ?>

both don't work. No .htaccess files used.

part of apache2.conf:

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>
<Directory /var/www/html>
        Order allow,deny
        Allow from all
        Require all granted
</Directory>

added the last Directory in an attempt to fix it.

So what is causing the error?

1

1 Answers

0
votes

So I decided to purge everything and all configs plus folders. After reinstalling i realized it migth just be

drwxr-xr-x  4 root root       4096 Jul 25 20:47 www

needed also to be

drwxr-xr-x  4 www-data www-data       4096 Jul 25 20:47 www

owned by www-data www-data Because now it is. But what i don't understand is how can index.html work in this folders and php does not.