diff --git a/public/simulate-nis2.php b/public/simulate-nis2.php index ccb969f..f4e32e1 100644 --- a/public/simulate-nis2.php +++ b/public/simulate-nis2.php @@ -52,7 +52,14 @@ if ($simParam === 'sim06') { // ── Avvia subprocess (pattern lg231 runCommand) ─────────────────────────────── $descriptors = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; $cwd = dirname($scriptPath); -$cmd = PHP_BINARY . ' ' . escapeshellarg($scriptPath); +// PHP_BINARY in PHP-FPM punta a php-fpm, non al CLI → cerca il binario CLI corretto +$phpBin = PHP_BINARY; +if (str_contains($phpBin, 'fpm') || !is_executable($phpBin)) { + foreach (['/usr/bin/php' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '/usr/bin/php', 'php'] as $try) { + if (is_executable($try) || shell_exec("which $try 2>/dev/null")) { $phpBin = $try; break; } + } +} +$cmd = $phpBin . ' ' . escapeshellarg($scriptPath); $proc = proc_open($cmd, $descriptors, $pipes, $cwd, $env); if (!is_resource($proc)) {