Running Linux Command from PHP

依然范特西╮ 提交于 2020-01-11 11:18:10

问题


I have a bit of a unique situation. I'm trying to run a video encoding program from a PHP script called Diascope, which relies on the 'convert' command provided by ImageMagick. I have a bash script that executes a really simple conversion and then it runs the application called Diascope. This is the conversion code, and the following does work, it creates the new file

convert image.jpg image.png

Shows no errors, but then I run Diascope like this

diascope -clean audio.txt

And I can see that Diascope loads property because it prints "Diascope 0.2.1":

diascope 0.2.1 (ms 2006-2010) slideshow generator See http://diascope.sf.net for documentation and updates.

Error: executable program not found: convert Please see the requirements for diascope in the release notes.

When I run shell_exec("whoami"); it prints "nobody"

So why can I run convert by itself, but the "diascope" process can't seem to utilize it? I have tried going into /usr/local/bin/convert and chmoding it to 777, but it didn't seem to have any effect, what else could I try here?

UPDATE: I should probably add that when I try to run diascope -clean audio.txt as root on the terminal, it creates the audio.flv file like it should, also I can't seem to sudo su nobody it returns This account is currently not available.


回答1:


PHP runs as the same user as apache, which is typically www-data or nobody. I believe you can use suPHP+apache to change the user that PHP runs under.



来源:https://stackoverflow.com/questions/8707040/running-linux-command-from-php

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