2

我想将可通过命令行(Linux 操作系统)访问的小程序安装到服务器并使用 PHP 运行它们。我想在我的机器上安装 Apache、vhost... 有没有办法在我的虚拟服务器上运行这些外部应用程序,在我的系统上,所以我可以试验 PHP 调用?

4

2 回答 2

2

我们一直都在这样做。我称它们为巫毒教页面。这是一些工作代码:

<?php
$command="uptime"; $output; $retval; $errors="";
exec ( $command ,  &$output, &$retval  );
echo $output[0]."\n";
unset($output);
?>

网页的输出为:

13:40:19 up 22 days, 23:14,  0 users,  load average: 0.04, 0.02, 0.00
于 2013-03-27T20:42:48.503 回答
1

您可以编写一些 shell 脚本 *.sh,它们将打开应用程序。您可以使用 php 命令“shell_exec”并运行这些 shell 脚本。

于 2013-03-27T20:09:33.480 回答