Skip to content
10% off any project with promo code10% off with code

PHP-FPM and Nginx Tuning: A Practical Checklist

Contents
  1. PHP-FPM: choosing the PM mode
  2. OPcache configuration
  3. Nginx worker connections
  4. FastCGI cache
  5. Keepalive and gzip
Published
Reading time
~1 min
Views
123
Reader rating
11 reviews
Author
Yevhen Fostenko
Senior Backend & DevOps Engineer
PHP-FPM and Nginx Tuning: A Practical Checklist Article
Need help with your website?
Describe the task on Telegram — I will assess it and suggest where to start. Reply within a day.
Message on Telegram
Free consultation and estimate. I reply quickly.

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.

Tags: nginxphp-fpmdevopslinuxserveroptimization
Need help with your website?
Describe the task on Telegram — I will assess it and suggest where to start. Reply within a day.
Message on Telegram
Free consultation and estimate. I reply quickly.

Related Articles

Optimising OpenCart: From 4 Seconds to 400 ms Article

Optimising OpenCart: From 4 Seconds to 400 ms

A slow OpenCart is one of the most common problems store owners run into. This walkthrough covers the process from analysis to result. Step 1: read the slow…

02/06/2026 189
Shared Hosting or VPS for a Store: When Moving Actually Pays Off Article

Shared Hosting or VPS for a Store: When Moving Actually Pays Off

The question of whether it is time to move from shared hosting to a VPS usually arises from a symptom rather than from theory: the store started slowing down…

06/08/2024 70

Reader reviews

5.0
Write a review