PHP警告:未知:未能打开stream

我最近编辑了Apache的httpd.conf文件,以使mod_rewrite正常工作。 我不知道这个问题是否来自这个问题,但是我从那天起就遇到了这个问题。
当我运行该软件时,这就是我在前端看到的东西 –

服务器错误网站在检索http:// localhost / prestashop /时遇到错误。 它可能是维护closures或configuration不正确。

没有特定的文件触发这个。 但是我看到,通常由4-5个php文件组成的小程序运行良好,但是具有大量文件的软件(如PrestaShop)则不能。
我检查了日志,这是我发现的。

[Wed Mar 16 19:33:39 2011] [error] [client ::1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 [Wed Mar 16 19:33:39 2011] [error] [client ::1] PHP Fatal error: Unknown: Failed opening required '/var/www/html/yomig/index.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0 [Wed Mar 16 19:33:39 2011] [error] [client ::1] File does not exist: /var/www/html/favicon.ico [Wed Mar 16 19:33:41 2011] [error] [client ::1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 [Wed Mar 16 19:33:41 2011] [error] [client ::1] PHP Fatal error: Unknown: Failed opening required '/var/www/html/yomig/index.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0 

遇到同样的错误,对我来说,这是因为在我的Mac上,我已经将DocumentRoot更改为我的用户Sites目录。

为了解决这个问题,我运行了recursion命令来确保Apache服务具有读权限。

 sudo chmod -R 755 ~/Sites 

如果您正在运行Fedora,请确保SELinux不会干扰。您可以使用以下命令修复此问题:

  sudo /sbin/restorecon -R /var/www/. 

更多信息在这里: linuxquestions.org/questions/linux-server-73/

我有同样的错误,我的问题是文件权限不正确。

 chmod 755 index.php 

为我工作。

在将错误的文件地址插入.htaccess时遇到此问题

 php_value auto_prepend_file "/home/user/wrong/address/config.php" 

所以如果你使用auto_prepend_file检查你的文件path。 它从.htaccess调用,所以PHP不能确定错误文件和行。

在我看来,真正的方法是:

 # add READ permission to all directories and files under your DocumentRoot sudo chmod +r /path/to/DocumentRoot/ -R # add EXECUTE permission to all DIRECTORIES under your DocumentRoot find /path/to/DocumentRoot/ -type d -exec chmod +x {} \; 

它发生在我今天与chmod o+x /home/user public_html chmod o+x /home/user index.php和解决办法是做chmod o+x /home/user这个目录必须有X,否则Apache服务器无法列出文件(即做ls

这里有一些指导如何解决它。 去 :

 cd /var/www sudo chown www-data:www-data * -R sudo usermod -a -G www-data username 

用您的用户名更改用户名。 我希望它有帮助。

我刚刚遇到了同样的问题,在我的情况下,这是由selinux引起的。 禁用它解决了这个问题。 不,我不需要在我的工作站上使用selinux,谢谢。

如果您忘记了您创build了Windows符号链接到不同的目录,并且该其他目录没有适当的权限,也会发生这种情况(尤其是混淆)。

这不是对问题的直接回答,但是我也遇到了同样的问题。 我在我的Ubuntu服务器VPS上安装了VSFTPD。 我可以上传文件,但是我上传的每个文件都没有执行权限(所有文件的权限均为“600”)。 这些post解释了正确地解释你必须做什么来configuration你的VSFTPD设置文件的默认权限:

  • 默认文件权限Apache / var / www /
  • 在Ubuntu上,vsFTPd默认上传的文件权限不起作用

有一次,这也发生在我身上。 当我search这个问题的时候,我得知当文件的权限被错误地设置为000(这意味着没有人可以读,写或者执行该文件)时会发生这种情况。 然后,我只是将我的文件权限权限更改为“读取和写入”,这对我来说很有用。

要更改mac上的文件权限设置,请执行以下操作:右键单击特定文件,然后单击获取信息从下拉菜单并参考共享和权限面板并将权限设置更改为读写

更多: http : //www.itoctopus.com/warning-unknown-failed-to-open-stream-permission-denied-in-unknown-on-line-0-error-in-joomla

检查dos和unix文件格式。 如果使用dos文件格式,可以在linux平台上看到这个问题。 使用下面的doc2unix命令,然后重试它应该工作dos2unix * .php

针对以下问题的解决scheme

 Wed Nov 12 07:50:19 2014] [error] [client IP1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 [Wed Nov 12 07:50:19 2014] [error] [client IP1] PHP Fatal error: Unknown: Failed opening required '/var/www/html/index.php' (include_path='.:/usr/share/pear: /usr/share/php') in Unknown on line 0 

转到文件夹htdocs

  cd htdocs 

执行

  chmod -R 755个网站 

不需要sudo!

只是引用user1992554的上面的答案这一个完美的为我在Linux Mint,摆脱警告:未能打开stream:权限被拒绝

cd / var / www
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data用户名

这是一个SELinux阻塞问题,Linux阻止了httpd访问。 这是解决scheme:

 <i>restorecon '/var/www/html/wiki/index.php'</i> <i>restorecon -R '/var/www/html/wiki/index.php'</i> <i>/sbin/restorecon '/var/www/html/wiki/index.php'</i> 

在Fedora 25中,事实certificate这是一个SE Linux的问题,通知给了这个解决scheme,为我工作。

setsebool -P httpd_read_user_content 1