The test with getenv(“PATH”) only returns an empty response报错解决办法

277次阅读
没有评论

The test with getenv(“PATH”) only returns an empty response报错解决办法The test with getenv(“PATH”) only returns an empty response报错解决办法The test with getenv(“PATH”) only returns an empty response 报错解决办法

因为我并没有遇见过这个错误,所以我只能结合官方文档和一些资料摸黑写(几乎相当于翻译一遍),希望有人能提供一下报错的样本。如果有什么问题,在下面提即可(这两天很闲)。

报错分析

按照 Nextcloud 的文档的说法,使用 php-fpm 时,系统环境变量(如 PATH,TMP 或其他)不会以与使用 php-cli 相同的方式自动填充。类似 getenv(’PATH’)这样的 PHP 调用可能会返回一个空的结果。

原文:When you are using phpfpm , system environment variables like PATH, TMP or others are not automatically populated in the same way as when using php-cli. A PHP call like getenv(PATH);  can therefore return an emptyresult. So you may need to manually configure environment variables in the appropropriate  phpfpm  ini/config file.

动手解决

所以,我们需要手动配置以下环境变量。配置文件一般位于以下目录:

Ubuntu/Mint CentOS/Red Hat/Fedora
/etc/php5/fpm/ /etc/phpfpm.d/

配置文件一般名为 www.conf。当然,因为实际环境的不同,文件名和文件所在的位置可能有所不同。

配置文件中一搬含有以下内容(如果没有可以自行添加):

删掉每一行前面的

;

,将注释取消掉。

执行

printenv PATH

命令,确认变量生效:


搜了一下,这的确是个有效的解决办法。不过因为没遇见过这个问题,实际效果未知。

GitHub issue:https://github.com/owncloud/core/issues/17504

 
吾爱互联
版权声明:本站原创文章,由 吾爱互联 2020-01-05发表,共计1077字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
载入中...