WordPress Elementor Multisite 環境で php-fpm を最適化する
環境
- debian
- CPU 8コア
- RAM 約10GB
- PHP-FPM 8.4
- Nginx
- WordPress + Elementor
- Multisite
PHP-FPM pool 設定
ファイル
/etc/php/8.4/fpm/pool.d/www.conf
推奨設定
pm = dynamic
pm.max_children = 80
pm.start_servers = 12
pm.min_spare_servers = 8
pm.max_spare_servers = 20
pm.max_requests = 1000
request_terminate_timeout = 300
平均 PHP メモリを 80MB と仮定
10GB RAM
– OS + nginx + mariadb ≈ 3GB
残り ≈ 7GB
7000MB / 80MB ≈ 87
pm.max_children = 80
PHP-FPM socketも変更
listen = /run/php/php8.4-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
確認すると、
; listen.mode = 0660
となっていたので、 「;」を外す
PHP 設定 php.ini ファイル
/etc/php/8.4/fpm/php.ini
memory_limit = 512M
max_execution_time = 300
max_input_vars = 5000
upload_max_filesize = 128M
post_max_size = 128M
大きな画像ファイルを扱うので、個人的に設定した数値
memory_limit = 1024M
max_execution_time = 300
max_input_vars = 5000
upload_max_filesize = 256M
post_max_size = 512M
OPcache も変更しよう
opcache.enable=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=50000
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.save_comments=1
php-fpm 再起動
設定を反映して
sudo systemctl restart php8.4-fpm

