这工作没有问题,但在EC2上运行系统更新后,我注意到我得到以下错误,无论我做什么,我无法解决这个问题。 它似乎没有向上移动一个目录,并试图访问“../../”作为文件path的一部分,而不是遍历两个目录。
我想要在这里生活的文件
/var/www/html/site/app/data/myFile.php
我的索引文件居住在这里:/var/www/html/site/public/rest/index.php
require __DIR__ . '/../../app/data/myFile.php';
错误
Fatal error: require(): Failed opening required '/var/www/html/site/public/rest/../../app/data/myFile.php' (include_path='.:/usr/share/pear:/usr/share/php')
由于我的名誉(1分),我不能写评论,但可能原因是两个:
require "/var/www/html/site/app/data/myFile.php"; 作品。 如果不是,请检查/var/www/html/site/app/data (及其所有内容)的所有者是否是运行服务器web的用户(运行top并查看与apache2 , apachectl或httpd对应的用户名)。 print __DIR__; 为了检查是否正确,并最终按照Stackoverfow上发布的这个问题: https : //stackoverflow.com/questions/31654069/wrong-dir-magic-constant-value 。 这是ununaswered,但有一些有趣的提示。