无法通过 php api 在 centos 上 运行 shellinabox

cannot run shellinabox through a php api on centos

我想通过phpapi在centos上启动shellinabox。

当用户点击 api 时,shellinaboxd -p 'portno' 命令应该被执行并且 shellinabox 应该在特定的端口号上启动。

但这并没有发生,而是出现了这个错误 错误:

Failed to find any available port [on tail -f /var/log/httpd/error_log] The code below runs correctly on ubuntu but not on centos.
Consider rest all things working fine.

$app->get('/test', function() {
    exec('shellinaboxd -p '.$port);
});

正在执行:

shellinaboxd -p 'someport' 在 bash 上也可以正常工作。

我的系统上安装了 php5.5 和 apache2。

错误消息 Failed to find any available port 告诉您端口已被使用。

尝试不同的端口。

我想出了一个解决办法。 Centos 是 SELINUX(安全 linux)。因此它不允许来自进程的任何日志记录操作,例如 php api(在我的例子中,其用户是 apache)在其默认模式下 "enforcing".

所以把SELINUX模式改成:

'SELINUX=disabled' 在 /etc/selinux/config

然后重启。

它还有一种模式,即宽容模式。 在这里阅读更多相关信息:https://wiki.centos.org/HowTos/SELinux