run external programs on virtual server

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 02:39:25

问题


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?


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/15668325/run-external-programs-on-virtual-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!