PHP exec() has been disabled for security reasons
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了PHP exec() has been disabled for security reasons,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1748字,纯文字阅读大概需要3分钟。
内容图文
一、问题
exec() has been disabled for security reasons
:翻译:出于安全原因,已禁用exec()- 代码
exec('php ' . $path . 'think optimize:schema --table ' . $tableName);
二、分析
exec()
被禁用,这应该是个配置,而PHP
的配置文件就在php.ini
中
- 1、我们可以找到这个配置并修改一下,然后
重启PHP
即可~ - 2、或者:用类似的函数
shell_exec()
代替函数exec()
三、解决
1、法一(推荐):使用shell_exec()方法代替exec()方法
shell_exec('php ' . $path . 'think optimize:schema --table ' . $tableName);
shell_exec(sprintf('cd %s', $file));
2、法二:php配置文件中不禁用exec方法
1)、找到php.ini文件位置
- 使用命令
php --ini
,可以知道当前的php使用的配置文件位置,如下:
Configuration File (php.ini) Path: /www/web/php/72/etc
Loaded Configuration File: /www/web/php/72/etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
2)、在php.ini文件中找到disable_functions配置并去除exec
- 在
php.ini
文件中找到disable_functions
配置,我们可以看到,exec
确实被禁用了
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names.
; http://php.net/disable-functions
disable_functions = passthru,exec,system,chroot,chgrp,chown,popen,proc_open,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru
- 去除
exec,
并保存文件,如下:
disable_functions = passthru,system,chroot,chgrp,chown,popen,proc_open,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru
3)、重启php服务
- 重启PHP:
service php-fpm restart
- 如果提示权限不足, 请用:
sudo service php-fpm restart
内容总结
以上是互联网集市为您收集整理的PHP exec() has been disabled for security reasons全部内容,希望文章能够帮你解决PHP exec() has been disabled for security reasons所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。