简体   繁体   English

PHP的require_once找不到绝对路径的文件?

[英]php require_once not finding file with absolute path?

I just started setting up the google ads php library and right off the bat am having super frustrating troubles. 我刚刚开始设置google ads php库,马上就遇到了非常令人沮丧的麻烦。

I'm running Arch Linux, and I have all my files in /var/lib/googleads 我正在运行Arch Linux,并且所有文件都在/ var / lib / googleads中

Trying to run GetRefreshToken.php, it requires a file called init.php in the same directory. 尝试运行GetRefreshToken.php,它需要在同一目录中有一个名为init.php的文件。 Here is that line: 这是这行:

require_once dirname(__FILE__) . '/init.php';

When I run this php file, I get this error: 当我运行此php文件时,出现此错误:

Fatal error: require_once(): Failed opening required '/var/lib/googleads/examples/AdWords/Auth/init.php' (include_path='.:/usr/share/pear') in /var/lib/googleads/examples/AdWords/Auth/GetRefreshToken.php on line 30 致命错误:require_once():无法在/ var / lib / googleads /中打开所需的'/var/lib/googleads/examples/AdWords/Auth/init.php'(include_path ='。:/ usr / share / pear')第30行上的examples / AdWords / Auth / GetRefreshToken.php

Even though as you can clearly see, the absolute path it's looking for is correct, and I even have it set at 777 permissions for now. 即使您可以清楚地看到,它正在寻找的绝对路径也是正确的,并且我现在甚至将其设置为777权限。

-rwxrwxrwx 1 root root 1.4K Nov 20 10:17 /var/lib/googleads/examples/AdWords/Auth/init.php -rwxrwxrwx 1根root 1.4K Nov 20 10:17 /var/lib/googleads/examples/AdWords/Auth/init.php

NO idea what's going on here. 不知道这是怎么回事。 Can anyone help? 有人可以帮忙吗?

I know this was quick, but I thought I'd post the answer for anyone else who runs across this problem. 我知道这很快,但是我想我会将答案发布给遇到此问题的其他任何人。

PHP didn't have access to files in /var/lib, which I found is set by the open_basedir line in php.ini, so I added /var/lib to that line and all is working correctly. PHP无法访问/ var / lib中的文件,我发现该文件是由php.ini中的open_basedir行设置的,因此我在该行中添加了/ var / lib,并且一切正常。

open_basedir = /var/www:/home/:/tmp/:/usr/share/pear/:/var/named/:/root/:/var/lib/: open_basedir = / var / www:/ home /:/ tmp /:/ usr / share / pear /:/ var / named /:/ root /:/ var / lib /:

Hopefully this can help someone down the road! 希望这可以帮助某人!

在您的init.php或GetRefreshToken.php中将其(include_path='.:/usr/share/pear')更改为其正确的路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM