Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尽管设置了include_path,但未包含php文件_Php_Apache - Fatal编程技术网

尽管设置了include_path,但未包含php文件

尽管设置了include_path,但未包含php文件,php,apache,Php,Apache,我的Linux机器上运行着一台apache2服务器。我通过将include_path设置为来编辑文件/etc/php5/apache2/php.ini include_path = ".:/usr/share/php:/var/www/subdir" 为了确保我没有更改错误的文件,我还编辑了我在计算机上找到的所有其他php.ini文件(还有一个),并检查了phpinfo()的输出,它从上面打印了正确的include_路径。(我还重新启动了apache2。) 然而,当我使用像 use some\

我的Linux机器上运行着一台apache2服务器。我通过将include_path设置为来编辑文件/etc/php5/apache2/php.ini

include_path = ".:/usr/share/php:/var/www/subdir"
为了确保我没有更改错误的文件,我还编辑了我在计算机上找到的所有其他php.ini文件(还有一个),并检查了phpinfo()的输出,它从上面打印了正确的include_路径。(我还重新启动了apache2。)

然而,当我使用像

use some\name\space;
require_once('./subsubdir/file.php');
在文件start.php(位于另一个目录/var/www/subdir/anothersubdir/)中,require_once命令不起作用,因为我在apache日志文件中遇到以下错误

[error] [client 127.0.0.1] PHP Fatal error:  require_once(): Failed opening required './subsubdir/file.php' (include_path='.:/usr/share/php:/var/www/subdir') in /var/www/subdir/anothersubdir/start.php on line x
我也试过了

require_once('/subsubdir/file.php');
但它没有起作用。当我设置了如上所示的include_路径时,如何导入file.php


提前多谢

尝试重新启动Apache,以清除内部缓存。

我要问自己的第一个问题是:

  • Web服务器是否在chroot环境中运行
  • 目标文件的权限是什么
回答这两个问题的简单方法是:

print getcwd() . "<hr />\n";
$t='/var/www/subdir/anothersubdir/subsubdir/file.php';

function show_permissions($path) 
{
   if (strlen($path)>1) {
       show_permissions(dirname($path));
   }
   if (is_readable($path)) {
       print "Permissions for $path: " . var_export(stat($path)) . "<br />";
   } else {
       print "can't read $path <br /> \n";
   }
}
print getcwd()。“
\n”; $t='/var/www/subdir/anothersubdir/subsubdir/file.php'; 函数显示权限($path) { 如果(strlen($path)>1){ 显示_权限(dirname($path)); } if(是否可读($path)){ 打印“$path的权限:”.var_导出(stat($path))。“
”; }否则{ 打印“无法读取$path
\n”; } }

(我的钱将用于权限问题,而不是路径问题)

感谢您的回复!事实上,is_readable会产生'false',在我看来,这意味着无法找到该文件,因为我将file.php的权限设置为rwxrwx。此外,使用相对路径(即.../subdir/file.php)也可以很好地工作,即使不增加权限。(但在我看来,使用相对路径是一团糟,因为我在几个目录中有几个文件相互需要。)顺便说一下,getcwd()产生了预期的输出,即start.php所在的目录。嗯,总是可以选择将根目录保存在全局变量中…”意味着找不到文件…rwxrwxrwx”-不一定,它所在的目录也必须是可读的。“使用相对路径……有效”,那么php很可能正在chroot监狱中运行。“getcwd()产生了…start.php所在的目录”-这三条语句不一致