From 2f0831aa09f98c7c2e3e92776529822af770c56e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9drix?= <cedric@abonnel.fr>
Date: Sun, 23 Mar 2025 21:55:54 +0100
Subject: [PATCH] configuraiton des modules opcache et apcu

---
 scripts/server-httpd/install-php8-3.sh | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/scripts/server-httpd/install-php8-3.sh b/scripts/server-httpd/install-php8-3.sh
index e2684d0..56adef9 100644
--- a/scripts/server-httpd/install-php8-3.sh
+++ b/scripts/server-httpd/install-php8-3.sh
@@ -97,6 +97,7 @@ fi
 
 # Configuration de PHP-FPM si ce n'est pas déjà fait
 PHP_INI="/etc/php/$PHP_VERSION/fpm/php.ini"
+PHP_INI_DIR="/etc/php/${PHP_VERSION}/fpm/conf.d"
 
 if grep -q "memory_limit = 512M" "$PHP_INI"; then
     echo -e "${GREEN}Configuration de PHP-FPM déjà optimisée.${RESET}"
@@ -111,6 +112,31 @@ else
     systemctl restart php$PHP_VERSION-fpm || { echo -e "${RED}Échec du redémarrage de PHP-FPM${RESET}"; exit 1; }
 fi
 
+# Configuration OPCache
+OPCACHE_INI="${PHP_INI_DIR}/10-opcache.ini"
+cat > "$OPCACHE_INI" <<EOF
+; Configuration OPcache optimisée
+opcache.enable=1
+opcache.memory_consumption=128
+opcache.interned_strings_buffer=16
+opcache.max_accelerated_files=10000
+opcache.revalidate_freq=60
+opcache.fast_shutdown=1
+opcache.enable_cli=1
+EOF
+echo "==> Fichier $OPCACHE_INI mis à jour."
+
+# Configuration APCu
+APCU_INI="${PHP_INI_DIR}/20-apcu.ini"
+cat > "$APCU_INI" <<EOF
+; Configuration APCu optimisée
+apc.enabled=1
+apc.shm_size=64M
+apc.ttl=7200
+apc.enable_cli=0
+EOF
+echo "==> Fichier $APCU_INI mis à jour."
+
 # Test de la configuration Apache
 if systemctl is-active --quiet apache2; then
     read -rp "Voulez-vous tester le support de PHP par Apache ? (o/n) : " test_php