简体   繁体   English

执行shell命令在AWS中不起作用

[英]Executing shell command not working in AWS

I'm facing problem to execute shell command in AWS but it works normally in my local computer. 我在执行AWS中的shell命令时遇到问题,但它在我的本地计算机中正常运行。 What I've used is pasted below: 我用过的粘贴在下面:

$cmd='ffmpeg -i media/dream_theatre.jpg -r 1 media/66_dream_theatre.avi';
$output = shell_exec($cmd);

Same script works in my local computer but does not in AWS. 相同的脚本可在我的本地计算机上运行,​​但不适用于AWS。 However when I type this ffmpeg -i media/dream_theatre.jpg -r 1 media/66_dream_theatre.avi in AWS terminal CLI it works normally so it confirms correct installation of ffmpeg in AWS. 但是,当我在AWS终端CLI中键入ffmpeg -i media/dream_theatre.jpg -r 1 media/66_dream_theatre.avi ,它可以正常工作,因此可以确认ffmpeg在AWS中的正确安装。

You probably don't have ffmpeg in the default PATH . 您可能在默认PATH没有ffmpeg Try replacing ffmpeg with the result of which ffmpeg . 尝试更换ffmpeg与结果which ffmpeg

I was trying a different shell command, but it didn't work in AWS Ubuntu instance although it worked locally. 我尝试使用其他shell命令,但尽管它在本地运行,但在AWS Ubuntu实例中不起作用。 From a few other answers, I got to know that apache should operate as root. 从其他一些答案中,我知道apache应该以root身份运行。

Depending on your installation, you'll have to go to /etc/apache2/conf/httpd.conf or in LAMP/Ubuntu/Apache's case, it was 根据您的安装,您必须转到/etc/apache2/conf/httpd.conf或在LAMP / Ubuntu / Apache的情况下

/etc/apache2/apache2.conf

Look for Users and Groups in the file and change it to root (not recommended for production servers). 在文件中查找“ UsersGroups ,并将其更改为root (不建议用于生产服务器)。 Apache might throw an error, that goes something like Apache可能会抛出一个错误,类似于

Apache has not been designed to serve pages while running as root

In my case, I'm running ubuntu instance on AWS, so I just gave Users and Groups as 'ubuntu', and shell_exec started working on PHP :) 就我而言,我在AWS上运行ubuntu实例,因此我只是给Users和Groups作为'ubuntu',然后shell_exec开始在PHP上工作:)

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

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