问题原文
原帖链接 · curv · CC BY-SA 3.0
This was working without issue but after running a system update on EC2, I noticed I was getting the following error and no matter what I do I can not resolve this. It just doesn't seem to move up a directory and tries to access '../../' as part of the file path rather than traversing up two directories.
The file I am trying to require lives here
/var/www/html/site/app/data/myFile.php
My index file lives here: /var/www/html/site/public/rest/index.php
require __DIR__ . '/../../app/data/myFile.php';
The error
Fatal error: require(): Failed opening required '/var/www/html/site/public/rest/../../app/data/myFile.php' (include_path='.:/usr/share/pear:/usr/share/php')
已采纳解答
原帖链接 · pietrop · CC BY-SA 3.0
I can't write a comment due to my reputation (1 pt) but probably the reasons are two:
- Check if
require "/var/www/html/site/app/data/myFile.php";works. If not, check if the owner of/var/www/html/site/app/data(and all of its content) is the user running the server web (runtopand see the username corresponding toapache2,apachectlorhttpd). - Try to execute
print __DIR__;in order to check if it is correct and eventually follow this question posted on Stackoverlfow: https://stackoverflow.com/questions/31654069/wrong-dir-magic-constant-value. It's ununaswered but has some interesting tips.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
