Good day! There is a need to change the bitrate of the song right on the server (centos, php, mysql, apache). For this I use lame

On the local server, everything works fine, but nothing happens on the global one. Here is the command I use

exec("lame -b 128 ".$_SERVER['DOCUMENT_ROOT'].$mp3_name." ".$_SERVER['DOCUMENT_ROOT'].'/music/'.$dataf['last_id_file'].".mp3"); 
  • Pass the second parameter to exec , it will be the output. You may not need lame , or you have no right to launch it, or something else. As an option - to display the command that you are trying to execute and run it with pens. You will not get rid of errors with rights to launch, but at least you will be sure that such a command can be executed normally. - BOPOH
  • lame is exactly installed, I even started it from the console on the global server. Everything works. If you add the second argument to exec then through var_dump this variable looks like this array (0) {} (local server), tried using passthru ($ com, $ out_code) on local returns 0, nothing on global, or rather, on var_dump NULL - M11
  • Perhaps exec is included in the disabled_functions in php settings. - antage

1 answer 1

Check whether safe_mode is enabled for php. The restriction of using functions of php can also be enabled - disable_functions .

It may also be that the user from whom the web server is running does not have a shell. Try this: echo exec("whoami"); After receiving the answer, check if there is a valid shell in the / etc / passwd file: echo exec("cat /etc/passwd"); .

Alternatively, you can also output the result of the command execution to the file: exec("/usr/bin/some_command > /full/path/to/root/dir/log.txt");

But most likely the lame command is missing in the binary directories search directories for the user from which it is launched. From the console on the server, make which lame , then correct your command by specifying the full path to the binary, for example exec("/usr/local/bin/lame [options] [filename]");

  • one
    It was enough to remove the necessary functions from disable_functions, thanks a lot! - M11