How to Optimize Nginx and PHP-FPM VestaCP CentOS

by Sandy

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

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” :

From:

worker_connections 1024;

To :

worker_connections 5000;

Once you changed this value restart nginx service :

service nginx restart

PHP-FPM

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 (domain.com.conf) 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
nano your-website-name.com.conf

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 :

md-donate

Donate with Paytm :

md-donate

You may also like

2
Leave a Reply

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
subin babuMit Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Mit
Guest
Mit

Thank you so much, work fine…

subin babu
Guest

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