How to enable and customize PHP-FPM directives/pool for a domain or server wide :: cPanel

What is PHP-FPM?

PHP FastCGI Process Manager (PHP-FPM) is an alternative FastCGI daemon for PHP that allows a website to handle strenuous loads. It also allows for a host to set specific amounts of resources to process a domain’s requests. PHP-FPM maintains “pools” (workers available to respond to PHP requests) to accomplish this. These “pools” of workers allow the website to handle more requests than it normally could.

PHP-FPM is faster than traditional CGI-based methods such as SUPHP for multi-user PHP environments. It does not overload a system’s memory with PHP from Apache processes like ruid2+php-dso does. This method is useful when a user receives extra traffic that requires resources to process it. For example, your website may receive a spike in traffic after a TV show features it or is linked from a popular website.

How to install PHP-FPM?

cPanel supports PHP-FPM with the help of EasyApache 4 and Multi-PHP manager. You can check the Multi-PHP manager to see if the PHP-FPM is installed or enabled on the server. If the required packages are not enabled, you can directly install them from Multi-PHP manager itself. You may install them using yum too.

yum install ea-php54-php-fpm ea-php55-php-fpm ea-php56-php-fpm ea-php70-php-fpm ea-php71-php-fpm ea-apache24-mod_proxy_fcgi

How to customize Pool values?

Once you have installed the necessary package through EasyApache 4, you can enable PHP-FPM to accounts using Multi-PHP manager. However, you will only be able to edit the pool values per domain basis and only a few directives through the Multi-PHP manager. There will be cases where you have a large number of accounts on the server and a default value of directive is very low (Default value for pm.max_children is 5). Then you need to customize the cPanel template and use it to generate pool configuration for all the domains.

Set a domain’s pool options

Go to Multi-PHP manager and Click ‘Pool Options’ next to your desired domain. The system will display the available options and their defaults and limits. Enter your desired options for Max Children, Process Idle Timeout (s), and Max Requests. Click Save.

How to customize PHP-FPM values server-wide?

The system uses the following configuration files to implement PHP-FPM:

/var/cpanel/ApachePHPFPM/system.yaml : This file contains system level settings.
/var/cpanel/ApachePHPFPM/system_pool_defaults.yaml: The system uses this file to generate each domain’s pool.

You can use the following as an example.

A complete configuration directive line would resemble the following example:

php_value_open_basedir: { name: ‘php_value[open_basedir]’, value: “[% documentroot %]” }

Once you have made the changes you will need to run the rebuild command to apply the same to all the domains(those configured with PHP-FPM).

Configuration of HAProxy Load Balancer on CentOS

HAProxy stands for High Availability proxy.  It is a very fast and reliable solution for high availability and load balancing. HAProxy is used as TCP/HTTP Load Balancer and for proxy Solutions.The HAProxy application will share the workload with multiple servers.

Steps for Installation and configuring  HAproxy

Step 1: Before proceeding with the installation of  HAProxy in the server, we need to install epel repository on our system depending on the operating system version using the following command.
Continue reading…

Squid proxy installation in windows server

Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. Squid has variety of uses and advantages such as speeding up web browsing for end user, reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. It also can work as web filtering and can control the browsing traffic.

Squid is based on the Harvest Cache Daemon developed in the early 1990’s. It was one of two forks from the codebase after the Harvest project ran to completion. Continue reading…