CentosControl PanelLinuxVesta CP

How to Optimize Nginx and PHP-FPM VestaCP CentOS

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

Sandeep B.

I'm a system admin and php developer and currently working as System Admin In CWP Control panel, expertise in Linux and Windows administration RHEL certified admin.

Related Articles

8 Comments

  1. Dear
    How are you?

    Could you help us make a tutorial on how to install prestashop with Nginx and PHP-FPM, CWP
    thank you

      1. I checked the manual and I have the same error
        404 not found nginx

        and when I change the name of the admin the following error appears
        403 Forbidden
        nginx/1.22.0

      2. Dear
        Sandeep B
        How are you

        I have found the problem.

        permissions are not changed in web mode. I had to do console mode and everything worked.

        Thank you

  2. 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…

Leave a Reply

Your email address will not be published.

Back to top button