How to Optimize Nginx and PHP-FPM VestaCP CentOS

by Sandeep B.

In this tutorial we’ll do optimization for Nginx and PHP-FPM under VestaCP, this tutorial will also work if you’re using LEMP (nginx + php-fpm). Nginx and PHP-FPM are the best choices who need speed and security for the websites, here Nginx will server the static content and PHP-FPM will work as Application server which drastically improve the First byte/First Ping for your websites and your web page loads very quickly.

Anyways You’ll think at this point if the NGINX & PHP_FPM is good then why we’ll be optimizing it? Because those settings are set to minimal and you can optimize it and improve the performance of your website even more. SO lets get started :


Nginx configs are by default located under at /etc/nginx  :

Edit Nginx Config :

nano /etc/nginx/nginx.conf

1st :

Once you open the file for edit you need to change this “worker_rlimit_nofile” value :
From :

#worker_rlimit_nofile    65535;

To :

worker_rlimit_nofile    65535;

uncomment the line remove “#”

*Value “65535” can be different on your server

2nd :

find the “worker_connections” :


worker_connections 1024;

To :

worker_connections 5000;

Once you changed this value restart nginx service :

service nginx restart


By default php-fpm configs are by default located under at /etc/php-fpm.d

when you navigate to this dir you’ll find bunch of configs ( are located under this dir open the config file for your website and change the value :

open your website domain name config file :

cd /etc/php-fpm.d

And change this Values :-

From :

pm.max_children = 4
pm.max_requests = 4000

To :

pm.max_children = 10
pm.max_requests = 6000

once you saved the config restart PHP-FPM service :

service php-fpm restart

This are the optimal settings which can handle 2000-3000 real time visitor according to your server config very easily even more.

Also check : How to Install PHP OPCache APC/APCu Memcached and Redis on VestaCP CentOS

If this post helps you in any way please consider a donation

Donate with PayPal :


You may also like


Mit March 9, 2019 - 4:42 pm

Thank you so much, work fine…

subin babu May 6, 2019 - 3:24 am

Hi, is there any tutorial on how to install Litespeed server, MariaDB and PHP on Ubuntu 18.04? thank you

azlan February 17, 2021 - 9:26 am

if this setting can handle between 2k – 3k visitor at a time… how to change so that it can accomodate double the visitor… let say 5k – 6k visitor at a time…

Sandeep B. February 18, 2021 - 8:15 am

increase the php-fpm pm.max_children to 15 that’s it.


Leave a Comment