可能是BT宝塔安装composer,也可能是执行

composer require --dev PHPstan/phpstan命令

无论是干什么出现的这段代码 putenv() has been disabled for security reasons 解决是非常简单的,根本原因就是PHP里禁用了putenv

PHP Warning: putenv() has been disabled for security reasons in phar:///usr/local/bin/composer/vendor/composer/xdebug-handler/src/Process.php on line 149

Warning: putenv() has been disabled for security reasons in phar:///usr/local/bin/composer/vendor/composer/xdebug-handler/src/Process.php on line 149
PHP Warning: putenv() has been disabled for security reasons in phar:///usr/local/bin/composer/bin/composer on line 57

Warning: putenv() has been disabled for security reasons in phar:///usr/local/bin/composer/bin/composer on line 57

两种解决办法

 

方法一:

打开配置文件php.ini,找到disable_functions字符串,把后面的putenv删除即可正常安装。

方法二:

宝塔面板的话,我的版本是7.2,就找到 PHP7.2管理→禁用函数→删除putenv,重载配置文件后即可正常安装

方法三:多版本PHP共存的处理

按上面操作后错误还在,你就要查看服务器上是不是还安装了其他PHP版本,

宝塔面板是支持多版本PHP共存的,所以你需要把别的版本PHP的 “putenv” 也删掉。

 

发表回复

后才能评论