phantommagick icon indicating copy to clipboard operation
phantommagick copied to clipboard

Problem on NGINX server.

Open DominikStyp opened this issue 7 years ago • 0 comments

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);
}

DominikStyp avatar Apr 10 '17 21:04 DominikStyp