run external programs on virtual server

2019-05-23 23:31发布

I want to install small programs accessible through the command line (of linux OS) to a server and run them with PHP. I want to install Apache, vhost on my machine... Is there a way to run these external applications on my virtual server, on my system, so i can experiment with PHP calls?

2条回答
时光不老,我们不散
2楼-- · 2019-05-23 23:56

We do exactly this all the time. I call them voodoo pages. Here's some working code:

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

And the output to the webpage served:

13:40:19 up 22 days, 23:14,  0 users,  load average: 0.04, 0.02, 0.00
查看更多
小情绪 Triste *
3楼-- · 2019-05-24 00:18

you could write some shell scripts *.sh and they will open the applications. you could use the php command "shell_exec" and run these shell scripts.

查看更多
登录 后发表回答