简体   繁体   English

PHP shell_exec将无法运行ls

[英]PHP shell_exec will not run ls

I am running the following php script: 我正在运行以下php脚本:

<?php

ini_set('display_errors', 'On');
error_reporting(E_ALL);

date_default_timezone_set('UTC');

echo nl2br("Before\n\n");

$out = shell_exec("ls -lart");
echo "<pre>$out</pre>";

echo nl2br("After\n\n");


?>

I cannot get shell_exec or exec to work at all. 我根本无法使shell_execexec正常工作。 The script above produces: 上面的脚本产生:

Before
After

but nothing in between. 但两者之间什么也没有。

I think shell_exec function is disabled in your php.ini . 我认为shell_exec函数在您的php.ini中已禁用。 You can check it by 您可以通过以下方式检查

if(function_exists('shell_exec')) {
    echo "shell_exec is enabled";
} else {
    echo "shell_exec is disabled";
}

Open your php.ini and navigate to section disable_functions 打开您的php.ini并导航到disable_functions部分

If shell_exec is listed under there , remove it. 如果在该目录下列出了shell_exec,请将其删除。

Then restart apache / php handler. 然后重新启动apache / php处理程序。

Also If Safe Mode is enabled this function will not be available. 同样,如果启用了安全模式,此功能将不可用。 You need to disable it. 您需要禁用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM