Warning: putenv() has been disabled for security reasons

文章讲述了在开发环境中,初次尝试使用ThinkPHPV6.1.4时遇到Composer安装警告,因为putenv被PHP安全策略禁用。给出了三种解决方案:在宝塔中删除禁用函数、修改php.ini配置移除putenv或备份后恢复默认设置,以及重启php-fpm-7.4服务。
摘要由CSDN通过智能技术生成

开发环境:

PHP:7.4

宝塔:7.9.0

ThinkPHP:V6.1.4

初次安装tp6时出错:

D:\wwwroot>composer create-project topthink/think thinktp6

Warning: putenv() has been disabled for security reasons in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/composer/xdebug-handler/src/Process.php on line 97

Warning: putenv() has been disabled for security reasons in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Util/Platform.php on line 80
Creating a "topthink/think" project at "./thinktp6"
Cannot use topthink/think's latest version v8.0.0 as it requires php >=8.0.0 which is not satisfied by your platform.
Installing topthink/think (v6.1.0)
  - Downloading topthink/think (v6.1.0)
  - Installing topthink/think (v6.1.0): Extracting archive
Created project in D:\wwwroot\thinktp6
Composer could not detect the root package (topthink/think) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version

In Platform.php line 80:

  putenv() has been disabled for security reasons

解决方法:

1.如果使用宝塔

去宝塔的php配置的【禁用函数】标签页里删掉禁用的函数putenv

2.修改php.ini配置

为了避免修改错误,请在修改前备份原来的php.ini文件!
修改php的配置文件php.ini,找到disable_functions这个地方,把putenv直接去掉或者备份一项disable_functions再去掉putenv即可。

3.保存并重启php-fpm-74服务

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kagamiGo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值