简体   繁体   English

在Shell和PHP之间通信?

[英]Communicate between Shell and PHP?

im going to write a php script that should do the following: 我要写一个PHP脚本,应该执行以下操作:

  • create user 创建用户
  • check for, download and install packages 检查,下载并安装软件包
  • download files with wget 用wget下载文件
  • move files 移动文件
  • set permissions 设定权限
  • start applications with screen 用屏幕启动应用程序
  • stop screen session 停止屏幕会话

i don't want to use default www-data user for that - how can i exec the cmd with another user? 我不想为此使用默认的www-data用户-我如何与另一个用户执行cmd?

Whats the best way to do that with PHP on Debian/Ubuntu ? 在Debian / Ubuntu上用PHP做到这一点的最佳方法是什么?

Maybe run a .sh file (+ params) with shell_exec() ? 也许使用shell_exec()运行.sh文件(+参数shell_exec()

Depending upon your need you can use .sh as well exec too 根据您的需要,您也可以使用.sh以及exec

If you have lots of commands under single action then you should prefer shell script 如果您在一次操作中有很多命令,那么您应该使用shell脚本

For one liners shell_exec works efficiently. 对于一个内衬, shell_exec有效地工作。

For more reference (regarding syntax) visit Documentation 有关更多参考(关于语法),请访问文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM