Search code examples
phpshell-execlame

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.

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?


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.