From 2e83e66932a627512c8e8977e2a88bacab9e7111 Mon Sep 17 00:00:00 2001 From: DevEnv nis2-agile Date: Tue, 10 Mar 2026 10:51:48 +0100 Subject: [PATCH] =?UTF-8?q?[FIX]=20simulate=20wrapper:=20PHP=5FBINARY?= =?UTF-8?q?=E2=86=92php-cli=20corretto=20(FPM=E2=89=A0CLI)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/simulate-nis2.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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)) {