linux - PHP exec sh: youtube-dl: command not found

one text

I'm running my website on Cyberpanel with OpenLiteSpeed in CentOS7.

Right now, I installed youtube-dl in CentOS7 and is working fine when running through terminal.

But when I run it using exec() then it returns: sh: youtube-dl: command not found

Example:

$command = "LC_ALL=en_US.UTF-8 youtube-dl -f best[ext=mp4] -o 'downloads/$file_name.mp4' https://www.youtube.com/watch?v=$vidID 2>&1";

exec($command, $output, $return_var);

print_r($output);

I tried running yt-dlp but it gives me same error. e.g command not found. However, both of them works fine when run using the Terminal.

Source