Install Latest PHP (7.4), PHP-FPM on CentOS 8 / RHEL 8
In this article, I’ll show you how to install the latest version of PHP with PHP-FPM on CentOS 8 / RHEL 8. Let’s start:
Table of Contents
Step 1 : Install Repositories
To install the latest PHP, we have to add two repositories on our server. The first one is the EPEL repository:
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
The second one is the Remi repository. Mainly we need this one. Remi repo requires EPEL repo.
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Step 2 : Install dnf-utils Package
Run this command to install dnf-utils:
sudo dnf install dnf-utils
Step 3 : Install PHP with PHP-FPM
See all available PHP version:
sudo dnf module list php
You’ll find PHP 7.2, 7.3, and 7.4 versions. Let’s install PHP 7.4 :
sudo dnf module install php:remi-7.4
Now install all necessary PHP modules including PHP-FPM:
sudo dnf install -y php-fpm php-cli php-common php-zip php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-pdo
To check the installed version of PHP, run this:
php -v
Step 4 : 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 your username. I’m going to setup for nginx.
user = nginx
group = nginx
Now find listen.owner
and listen.group
and change their values to your username too.
listen.owner = nginx
listen.group = nginx
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
Now restart web-server:
# nginx
sudo systemctl restart nginx
# apache
sudo systemctl restart httpd
Step 5 : More Info
The Nginx virtual host directive for PHP-FPM:
server {
# more config
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
These are some useful PHP-FPM commands:
sudo systemctl stop php-fpm
sudo systemctl restart php-fpm
sudo systemctl status php-fpm
Comment
Preview may take a few seconds to load.
Markdown Basics
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Italics *asterisks*
Bold **double asterisks**
Code
Inline Code
`backtick`Code Block```
Three back ticks and then enter your code blocks here.
```
Headers
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
Quotes
> type a greater than sign and start typing your quote.
Links
You can add links by adding text inside of [] and the link inside of (), like so:
Lists
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
Images
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of [], and the image URL inside of (), like so:
Dividers
To add a divider you can add three dashes or three asterisks:
--- or ***

Comments (0)