Question

I have a problem with running lame encoder via shell_exec script in php.

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. I have permissios of all files set to 777 just in case.

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.

Oh and this scirpt takes really max two seconds, so it coundn't be a timeout or anything. I also get no php or nginx errors.

How can I solve this?

Was it helpful?

Solution

Is lame on php's execution PATH? Try replacing lame with /usr/bin/lame or whatever.

How about the relative pathnames to the file arguments? Is ../furniture/ etc. correct from the current directory as seen by PHP? 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. If you own the file and it's only executable by the owner, apache won't be able to run it.

OTHER TIPS

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:

<?php
$output = "";
exec('lame -f -V 9 ../furniture/sound/107887.wav ../furniture/sound/107887.ogg',$output);
echo $output;
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top