Md Obydullah Follow I'm Md Obydullah. I build open-source projects and write about Laravel, Linux server, modern JavaScript and web development.

Install Latest PHP (7.3), PHP-FPM on CentOS 7

Last modified on July 21, 2019 1 min read

In this article, I’ll show you how to install the latest version of PHP with PHP-FPM on CentOS 7. We know that the FastCGI Process Manager (PHPFPM) is an alternative FastCGI daemon for PHP that allows a website to handle high loads. Let’s start:

Step 1 : Login to Server

At first, we need to login to our server via SSH. Open your terminal and run this command:

ssh root@IPaddress -p PORT

Step 2 : Install Repositories

We need two repositories. The first one is: EPEL. Run this command:

sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

The second one is: REMI. To install, run this command:

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Step 3 : Install yum-utils Package

Now we need to install yum-utils package by running this command:

sudo yum install yum-utils

Step 4 : Install PHP with PHP-FPM

We are going to install PHP 7.3. You can install another version too.

sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php73

To install PHP 7.1, PHP 7.2, you need to run command like this:

sudo yum-config-manager --enable remi-php71
sudo yum-config-manager --enable remi-php72

Now install PHP 7.3 with all necessary modules:

sudo yum -y install php php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-pdo php-pecl-apcu php-pecl-apcu-devel

To check the installed version of PHP, run this:

php -v

Step 5 : Configure PHP-FPM

Open php.ini file:

sudo nano /etc/php.ini

and add this line to the configuration file:

cgi.fix_pathinfo=0

Save and close the file. Next, open www.conf file:

sudo nano /etc/php-fpm.d/www.conf

Now find user and group and change their values to centos.

user = centos
group = centos

Now find listen.owner and listen.group and change their values to centos.

listen.owner = centos
listen.group = centos

Last, find listen parameter and change the line to:

listen = /var/run/php-fpm/php-fpm.sock

Save & close the file and start the PHP processor by typing:

sudo systemctl start php-fpm

Enable php-fpm to start on boot:

sudo systemctl enable php-fpm

Step 6 : Output

Now restart your web server to see the output:

Step 7 : Useful Commands

Here’s some useful PHP-FPM commands:

sudo systemctl stop php-fpm
sudo systemctl restart php-fpm
sudo systemctl status php-fpm

You're welcome to suggest any article to write!

Md Obydullah Follow I'm Md Obydullah. I build open-source projects and write about Laravel, Linux server, modern JavaScript and web development.

2 Replies to “Install Latest PHP (7.3), PHP-FPM on CentOS 7”

Leave a Reply

Your email address will not be published. Required fields are marked *