简体   繁体   English

php shell_exec中的Lame编码器命令无法通过http服务器运行

[英]Lame encoder command in php shell_exec doesn't work via http server

I have a problem with running lame encoder via shell_exec script in php. 我有一个问题,通过php中的shell_exec脚本运行lame编码器。

And the broke my problem to just this script and noticed that the script works if I run it via php command in terminal, but doesn't work if I open it in a browser. 并且我的问题突破了这个脚本,并注意到如果我通过终端中的php命令运行它,脚本可以正常工作,但如果我在浏览器中打开它则不起作用。 I have permissios of all files set to 777 just in case. 为了以防万一,我将所有文件的权限设置为777。

here's the code 这是代码

< ?php

exec('lame -f -V 9 ../furniture/sound/107887.wav ../furniture/sound/107887.ogg');

The thing is that script works if I run it in terminal with php command, but doesn't via browser. 问题是,如果我使用php命令在终端中运行脚本,但脚本不能通过浏览器运行。

Oh and this scirpt takes really max two seconds, so it coundn't be a timeout or anything. 哦,这个scirpt需要最多两秒钟,所以它不会是超时或任何事情。 I also get no php or nginx errors. 我也没有得到php或nginx错误。

How can I solve this? 我怎么解决这个问题?

Is lame on php's execution PATH ? 在php的执行PATH上蹩脚吗? Try replacing lame with /usr/bin/lame or whatever. 尝试用/usr/bin/lame或其他任何东西替换lame

How about the relative pathnames to the file arguments? 文件参数的相对路径名怎么样? Is ../furniture/ etc. correct from the current directory as seen by PHP? 从PHP看到的当前目录中../furniture/等是否正确? If in doubt, replace these with full pathnames too and see if that fixes the problem. 如果有疑问,请将这些替换为完整路径名,看看是否能解决问题。

Less likely but worth mentioning: You might want to check that lame itself has all its executable bits set. 不太可能但值得一提的是:您可能想要检查lame本身是否设置了所有可执行位。 If you own the file and it's only executable by the owner, apache won't be able to run it. 如果你拥有该文件并且它只能由所有者执行,那么apache将无法运行它。

There may be many reasons why it is not working from the webserver, perhaps resource or permission related. 可能有很多原因导致它无法通过网络服务器工作,可能是资源或权限相关。 You can find this out by using the second optional parameter of exec: 您可以使用exec的第二个可选参数找到它:

<?php
$output = "";
exec('lame -f -V 9 ../furniture/sound/107887.wav ../furniture/sound/107887.ogg',$output);
echo $output;
?>

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

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