[英]Accessing PHP includes above webroot when running as cron job
I'm trying to use a PHP script with sensitive information so I'm using includes to host the passwords above the webroot. 我正在尝试将PHP脚本与敏感信息一起使用,因此我正在使用include将密码托管在webroot上方。
The script works fine run via the browser, but when I run it as a crob job it generates error messages regarding includes. 该脚本可以通过浏览器正常运行,但是当我将其作为crob作业运行时,它会生成有关包含的错误消息。
The open_basedir setting is: /var/www/vhosts/xxx/:/tmp/ -- wondering if that's relevant here? open_basedir设置为:/ var / www / vhosts / xxx /:/ tmp /-想知道在这里是否相关?
Grateful for any suggestions on how to resolve this or workarounds. 感谢您提供有关如何解决此问题或解决方法的建议。
PHP Warning: include(../includes.php): failed to open stream: No such file or directory in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 6
PHP Warning: include(../includes.php): failed to open stream: No such file or directory in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 6
PHP Warning: include(): Failed opening '../includes.php' for inclusion (include_path='.:') in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 6
PHP Notice: Use of undefined constant API_KEY - assumed 'API_KEY' in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 88
PHP Notice: Use of undefined constant SCOPE - assumed 'SCOPE' in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 89
PHP Notice: Use of undefined constant REDIRECT_URI - assumed 'REDIRECT_URI' in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 91
这总是对我有用...
require_once("/full/path/to/your/file/includes.php");
What you are probably experiencing is that the Cronjob is using a different php.ini, and thus using different settings. 您可能正在体验的是Cronjob使用不同的php.ini,因此使用了不同的设置。 To confirm this you can create a php script that writes
phpinfo();
为了确认这一点,您可以创建一个编写
phpinfo();
的php脚本phpinfo();
results to a file. 结果到文件中。 In the output you will see which php.ini is being used.
在输出中,您将看到正在使用哪个php.ini。
What you can do to fix this is either: 您可以采取以下措施来解决此问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.