php 警告:出于安全原因,`exec()` 已被禁用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16421725/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 11:05:43  来源:igfitidea点击:

Warning: `exec()` has been disabled for security reasons

phpfatal-error

提问by Ma Jo

I upload a gif to my website. When is upload complete, i can see this error:

我上传了一个gif到我的网站。上传完成后,我可以看到此错误:

Warning: exec() has been disabled for security reasons in /data/web/virtuals/28995/virtual/www/include/functions/main.php on line 306

Fatal error: Call to undefined function execute() in /data/web/virtuals/28995/virtual/www/include/functions/main.php on line 309

And this is part from main.php

这是 main.php 的一部分

$owh = $width_old."x".$height_old;
$nwh = $final_width."x".$final_height;
if(!file_exists($temppic))
{
    $runinbg = "convert ".$file." -coalesce ".$temppic;
    $runconvert = execute("$runinbg");
}
$runinbg = "convert -size ".$owh." ".$temppic." -resize ".$nwh." ".$output;
$runconvert = execute("$runinbg");
return true;

Thank you for help! :-)

谢谢你的帮助!:-)

回答by raidenace

Just as additional information:

正如附加信息:

There is a php.ini directive called disable_functions. Functions added to this list will be disabled by PHP and when you try to execute those functions, you get this error. As mentioned, in all probability your hosting provider has added execto the disabled list. This is a common practice in shared hosting. You will need a dedicated server if you really want to run exec(or some hosting provider who provides pseudo-execfunctionality). It is a bad idea to trust a shared hosting provider who allows you to run exec unrestrained.

有一个 php.ini 指令叫做disable_functions. 添加到此列表的函数将被 PHP 禁用,当您尝试执行这些函数时,您会收到此错误。如前所述,您的托管服务提供商很可能已将其添加exec到禁用列表中。这是共享主机中的常见做法。如果您真的想运行exec(或一些提供pseudo-exec功能的托管服务提供商),您将需要一个专用服务器。It is a bad idea to trust a shared hosting provider who allows you to run exec unrestrained.

回答by Ma Jo

Those errors mean just what they say.

这些错误就是他们所说的。

Fatal error: Call to undefined function execute() 

You are calling a function that doesn't exist.

您正在调用一个不存在的函数。

Warning: exec() has been disabled for security reasons

Your web host has disabled the exec()method, you won't be able to run background scripts (like it appears you are attempting to do). You'll need to find another way to accomplish your goal, or find another web host.

您的虚拟主机已禁用该exec()方法,您将无法运行后台脚本(就像您正在尝试执行的操作一样)。您需要找到另一种方式来实现您的目标,或者寻找另一个网络主机。