phantommagick
phantommagick copied to clipboard
Problem on NGINX server.
I had huge problem running this plugin on NGINX due to one issue in Runner.php file:
elseif (Str::contains($uname, 'linux')) {
if (! shell_exec(escapeshellcmd("which {$binary}"))) {
return false;
}
}
You use which command inside shell_exec which always returns NULL. I've spent couple of hours discovering why. Finally I came into conclusion that NGINX doesn't set $_SERVER['PATH'] variable, and that's why following line won't work:
shell_exec(escapeshellcmd("which {$binary}"))
But there is easy fix for that. You just need to add the following line to your Runner::__construct() method in order to avoid this bug:
if(empty(getenv("PATH"))) {
$pathVar = shell_exec('echo $PATH');
if(empty($pathVar)){
throw new \Exception("Environmental PATH variable can't be empty!");
}
putenv("PATH=".$pathVar);
}