From 154f42ae09d6bd5d70fdba0b2d89c4fa261b7363 Mon Sep 17 00:00:00 2001 From: jknapp Date: Sun, 20 Jul 2025 16:52:04 -0700 Subject: [PATCH] Optimize memory usage for Apache and PHP-FPM, remove ioncube-loader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Apache mpm_event: Reduced StartServers from 10 to 2, adjusted spare threads and worker limits for container environments - PHP-FPM: Switched from static to dynamic process management with lower process counts (5 max children instead of 10) - Removed php-ioncube-loader from PHP 8.0 installation - Expected memory reduction: 60-70% in idle state while maintaining responsiveness 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- configs/default-index.conf | 12 ++++++------ scripts/create-php-config.sh | 9 ++++++--- scripts/install-php80.sh | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/configs/default-index.conf b/configs/default-index.conf index 36d9973..69f97ae 100644 --- a/configs/default-index.conf +++ b/configs/default-index.conf @@ -2,12 +2,12 @@ DirectoryIndex index.html index.htm index.php Alias "/ping" "/var/www/html" - StartServers 10 - MinSpareThreads 25 - MaxSpareThreads 75 + StartServers 2 + MinSpareThreads 10 + MaxSpareThreads 25 ThreadLimit 64 ThreadsPerChild 25 - MaxRequestWorkers 150 - ServerLimit 16 - MaxConnectionsPerChild 500 + MaxRequestWorkers 75 + ServerLimit 3 + MaxConnectionsPerChild 1000 \ No newline at end of file diff --git a/scripts/create-php-config.sh b/scripts/create-php-config.sh index 60a7490..93fd2e1 100644 --- a/scripts/create-php-config.sh +++ b/scripts/create-php-config.sh @@ -12,9 +12,12 @@ listen = /run/php-fpm/www.sock listen.owner = apache listen.group = apache -pm = static -pm.max_children = 10 -pm.max_requests = 150 +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +pm.max_requests = 500 slowlog = /etc/httpd/logs/error_log request_slowlog_timeout = 3s diff --git a/scripts/install-php80.sh b/scripts/install-php80.sh index b57f3aa..38a6271 100644 --- a/scripts/install-php80.sh +++ b/scripts/install-php80.sh @@ -2,5 +2,5 @@ dnf module enable php:remi-8.0 -y dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \ php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \ -php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd libzip php-cli +php-mysqlnd php-mbstring php-intl php-gd libzip php-cli exit 0 \ No newline at end of file