If you’re running a website on a server with Centos 7 installed, it’s important to optimize your server’s performance to ensure your website runs smoothly. One of the ways to do this is by tuning your php-fpm settings. Whether you’re using cPanel, CWP, or Core Server, optimizing your php-fpm settings can help you achieve better server performance. In this point, we’ll walk you through the steps to tune php-fpm settings on cPanel, CWP, and Core Server with Centos 7 installed. With our clear and concise instructions, you’ll be able to optimize your server’s php-fpm settings in no time.
1. First take backup your current PHP-FPM configuration file:
2. Edit the PHP-FPM configuration file
Open your PHP-FPM configuration file.You can edit the PHP-FPM configuration file using your preferred text editor. Here, we’ll use the vi editor:
i. Core server PHP-FPM file location
ii. cpanel PHP-FPM file location
iii. Cwp PHP-FPM file location
To find the PHP-FPM configuration file location, create an info.php file in the document root and run www.yourdomain.com/info.php in a browser.
3. You can make the following changes to optimize the PHP-FPM settings:
Change the number of child processes:
In the [www] section of the configuration file, you can adjust the number of child processes that PHP-FPM spawns to handle incoming requests. The default value is usually 5, but you can increase this value to match the number of CPU cores on your server. For example, if you have 8 CPU cores, you can set the value to:
Change the process manager:
By default, PHP-FPM uses the dynamic process manager, which spawns child processes as needed to handle incoming requests. However, if you have a high-traffic website, you can switch to the ondemand process manager, which only spawns child processes when needed. To switch to the ondemand process manager, set the following values in the [www] section:
Adjust the process priority:
You can also adjust the process priority to give more resources to certain child processes. This is useful if you have certain requests that require more resources than others. To adjust the process priority, you can set the following values in the [www] section.
Save and exit the configuration file.
Restart PHP-FPM
To apply the changes, you’ll need to restart the PHP-FPM service:
After restarting the service, PHP-FPM will use the new settings you specified in the configuration file.
It’s important to monitor the performance of your web server after making these changes, to ensure that the changes are having the desired effect. You can use tools like top, htop or monitoring solutions like Nagios or Zabbix to monitor your server’s resource usage and performance.
Note: The location of the configuration file may differ according to the panel