How to install PHP-FPM 7 on Centos
how to install PHP-FPM 7 on Centos or any specific version with Nginx
What is PHP-FPM?
PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.
FPM is a process manager to manage the FastCGI SAPI (Server API) in PHP.
Real-world Usage
PHP-FPM serves up millions of PHP requests without an issue for hundreds of websites, with more growing each day. At Open Source Bridge in Portland, Rasmus mentioned he now uses nginx + PHP-FPM at wepay.com, the company he works for.
Install PHP-FPM 7 on Centos
In centos 7 PHP and PHP-FPM is shipped with version 5.4 which is official but no longer is supported.
If we are using the latest versions of PHP then it will provide us with high performance and utilizes fewer system resources.
In this tutorial, we will be guiding you to install and configure PHP-FPM specfic version on UNIX socket.
Also guiding you to install specific PHP and PHP-FPM version 7.x
Prerequisites
Before starting the installation process, login user with Sudo privileges.
Enabling Remi Repository
PHP and PHP-FPM packages are available in various repository but we will be using Remi repository [Remi’s RPM repository](https://rpms.remirepo.net/)
The Remi repository depends on the epel-release repository. To install Remi first install Epel. Follow the following command to install both Epel and Remi.
sudo yum install epel-release yum-utils -y sudo yum install [](http://rpms.remirepo.net/enterprise/remi-release-7.rpm) -y
Installing PHP and PHP-FPM
Installing PHP 7.2 on Centos 7
Enable repository to install specific version
sudo yum-config-manager --enable remi-php72
Install php php-fpm and few common modules
sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd
[root@localhost php-fpm]# php -v && php-fpm -v PHP 7.4.6 (cli) (built: May 12 2020 08:09:15) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies PHP 7.4.6 (fpm-fcgi) (built: May 12 2020 08:09:15) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies
Installing PHP 7.3 on Centos 7
Enable repository to install a specific version
sudo yum-config-manager --enable remi-php73
Install PHP PHP-FPM and few common modules
sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd [root@localhost php-fpm]# php -v && php-fpm -v
[root@cpanel home]# cd /etc/php-fpm.d [root@cpanel home]# vim www.conf listen = /var/run/php-fpm/www.sock (this is for centos 7) listen = /run/php-fpm/www.sock (this is for centos 8) user = nginx group = nginx listen.owner = root listen.group = nginx listen.mode = 0660 [root@cpanel home]# chown nginx:nginx /var/run/php-fpm/www.sock [root@cpanel home]# vim /etc/nginx/conf.d/test.conf server { #listen 80; #root /usr/share/nginx/www; root /var/www/html/pureetables.com; index index.php index.html index.htm; server_name jagrush.in www.jagrush.in; error_log /var/log/nginx/pure.log; access_log /var/log/nginx/pure_access.log; location / { try_files $uri $uri/ =404; #try_files $uri $uri/ /index.html; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/html/pureetables.com; #root /usr/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm/www.sock; #fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
[root@cpanel home]# systemctl restart php-fpm [root@cpanel home]# systemctl restart nginx