02.06.2026
79
1 min read

PHP-FPM and Nginx Tuning: A Practical Checklist

PHP-FPM and Nginx Tuning: A Practical Checklist
Contents

    Getting Nginx and PHP-FPM right is the foundation of a fast e-commerce server. Here is a practical checklist drawn from real production work.

    PHP-FPM: choosing the PM mode

    On a VPS with fixed RAM, use pm = static or ondemand. Static gives predictable memory use; ondemand frees RAM during quiet hours.

    pm = ondemand
    pm.max_children = 20
    pm.process_idle_timeout = 10s

    OPcache configuration

    The parameters that actually matter in production:

    opcache.memory_consumption=256
    opcache.interned_strings_buffer=16
    opcache.max_accelerated_files=10000
    opcache.validate_timestamps=0

    Nginx worker connections

    Rule of thumb: worker_processes equals the number of CPU cores, worker_connections sits between 1024 and 4096 depending on RAM. Enable multi_accept on and use epoll.

    FastCGI cache

    Set up FastCGI cache with sensible exclusions (cart, logged-in users, POST requests). It is the single most effective way to speed up static pages.

    Keepalive and gzip

    Set keepalive_timeout to 65, enable gzip for text/html, CSS and JS, and turn on HTTP/2 for every HTTPS site. This cuts the number of TCP connections substantially.

    Related Articles
    Write a review
    Please login or register to review