PHP Warning:  exec has been disabled for security reasons in 文件路径 报错行数

使用php程序执 /www/xxxxx/XXXX/shop/shop/task/init.php 这个文件时报错;信息如下

[[email protected] ~]# /usr/bin/php /www/xxxxx/XXXX/shop/shop/task/init.php 

PHP Warning:  exec() has been disabled for security reasons in /www/xxxxx/XXXX/shop/shop/task/init.php on line 65

Warning: exec() has been disabled for security reasons in /www/xxxxx/XXXX/shop/shop/task/init.php on line 65

翻译:警告:exec()由于安全原因在/www/xxxxx/XXXX/shop/shop/task/init中被禁用。php在第65行

出现这个报错是由于php.ini 文件里默认是禁用了 exec 这个参数,所以执行不成功,需要去打开exec这个执行参数,如果不知道php.ini文件在哪里可以使用下面这条命令查找

[[email protected]~]# find / -name php.ini
/www/AAA/php/54/etc/php.ini

编辑php.ini

[[email protected] ~]# vim /www/AAA/php/54/etc/php.ini

PHP Warning:  exec has been disabled for security reasons in 文件路径 报错行数

删除掉 exec这个字段,wq! 保存退出

PHP Warning:  exec has been disabled for security reasons in 文件路径 报错行数

重启 php 服务

然后再去执行

[[email protected] ~]# /usr/bin/php /www/xxxxx/XXXX/shop/shop/task/init.php   就OK了

 

 

举一反三:

如果下次又出现这样的问题,但是由exec() 变成shell_exec()  等等,(下面红色标注的字体)都可以从这里去解决!

PHP Warning:  exec() has been disabled for security reasons in

passthru, system ,chroot,chgrp,chown,shell_exec,popen,proc_open,ini_alter,ini_restore,dl,openlog,syslog,r     eadlink,symlink,popepassthru

 

祝:大家早日排除故障,大吉大利!