Hi在Ubuntu 18.04上安装了LEMP堆栈,php 7.2.5服务器信息显示支持Shell Exec,不支持Shell Exec Zip
因此,我的一些插件显示此服务器未配置为Shell Zip引擎-请使用不同的引擎模式。要使'Shell Zip‘可用,请要求您的主机: 1.安装zip可执行文件并使其可供PHP访问。
我已经尝试过这个代码PHP - How to know if server allows shell_exec
if(function_exists('shell_exec')) {
echo "exec is enabled";
}
并使能该功能
但是,当我用下面的代码测试它是否可执行时,什么也没有发生。
正如DanFromGermany指出的,你可能会检查它是否是可执行的。像这样的东西就可以了
if(shell_exec('echo foobar') == 'foobar'){
echo 'shell_exec works';
}
或者尝试过此操作,也不返回任何内容,只返回白色页面
// Exec function exists.
// Exec is not disabled.
// Safe Mode is not on.
$exec_enabled =
function_exists('exec') &&
!in_array('exec', array_map('trim', explode(', ', ini_get('disable_functions')))) &&
strtolower(ini_get('safe_mode')) != 1
;
if($exec_enabled) { exec('blah'); }
我还检查了https://wpguru.co.uk/2014/01/how-to-test-if-a-shell-command-will-work-in-php/中的以下代码,它确实可以工作
// helper function
function checkShellCommand($command) {
$returnValue = shell_exec("$command");
if(empty($returnValue)) {
return false;
} else {
return true;
}
}
// test the shell command you'd like to use
if (!checkShellCommand('uname -a')) {
print 'This command cannot be executed.';
} else {
echo shell_exec('uname -a');
}
那么,谁能告诉我怎么才能让PHP访问它呢?
非常感谢
发布于 2018-06-25 03:31:26
解决这个问题的方法是
apt-get install zip unzip
https://stackoverflow.com/questions/50772717
复制相似问题