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

use*_*329 2 php

我在我的页面上收到此错误:

警告:出于安全原因,exec() 已在第 2036 行的 /home/a2297145/public_html/android/index.php 中被禁用

这是代码:

//
// Determine the size of a file
// 
public static function getFileSize($file)
{
    $sizeInBytes = filesize($file);

    // If filesize() fails (with larger files), try to get the size from unix command line.
    if (EncodeExplorer::getConfig("large_files") == true || !$sizeInBytes || $sizeInBytes < 0) {
        $sizeInBytes=exec("ls -l '$file' | awk '{print $5}'");
    }
    return $sizeInBytes;
}
Run Code Online (Sandbox Code Playgroud)

你能帮我解决这个问题吗?

小智 9

可以通过两种方式解决此错误:

  1. 检查服务器上“ php.ini ”文件中的“ disable_functions ”列表,然后从列表中删除“exec”或“shell_exec”。请记住重新启动 PHP-CGI 以应用这些更改。

或者

  1. 登录 WHM 并在左上角输入“multiPHP Manager”搜索框,然后转到 multiPHP manager。选择要禁用 exec() 或 shell_exec() 的 php 版本部分中的域。然后单击编辑 PHP-FPM 并向下滚动到 disable_functions 并通过编辑列表删除 exec() 或 shell_exec() 。