[英]403 - Forbidden error only with PHP serverwide, Raspberry Pi
it is my first question here. 这是我的第一个问题。 I get 403 - Forbidden for every php file.
我得到403-每个PHP文件均被禁止。 Tried with index.php and other names like test.php.
尝试使用index.php和其他名称(如test.php)。 Tried different subfolders and in /var/www/html directly.
在/ var / www / html中直接尝试了不同的子文件夹。
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.
安装了owncloud,pihole,mysql。 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.
必须解决“无主机路由”和新的外部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 因此文件夹为755,文件为644。所有者在/ var / www中也都是www-data:www-data
so th structure to my index.php example would be 所以我index.php示例的结构是
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上使用chmod 777,但仍然出现403错误。
index.php: index.php文件:
<?php echo "hello world"; ?>
or 要么
<?php phpinfo(); ?>
both don't work. 两者都不起作用。 No .htaccess files used.
没有使用.htaccess文件。
part of apache2.conf: 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? 那么是什么导致了错误呢?
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. www-data拥有www-data因为现在是。 But what i don't understand is how can index.html work in this folders and php does not.
但是我不明白的是index.html如何在此文件夹中工作而php却没有。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.