Share your love
Install PHP 8.2 on Rocky Linux 8 with Easy Steps

In this tutorial, we want to show you How To Install PHP 8.2 on Rocky Linux 8. PHP is the most widely used open-source and general-purpose server-side scripting language, and it is used mainly in web development to create dynamic websites and applications.
You can follow the steps below on the Orcacore website to install the current and latest PHP release, PHP 8.2.
Table of Contents
Steps To Install PHP 8.2 on Rocky Linux 8
To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Rocky Linux 8.
Install PHP 8.2 on Rocky Linux 8
In this guide, we will use the Remi RPM repositories which contain the new packages of PHP for RHEL-based systems such as CentOS, Rocky Linux, AlmaLinux, Fedora, etc.
First, update your local package index with the following command:
sudo dnf update -y
Install Epel Repository
Then, you need to install the Epel repository on your server:
sudo dnf -y install epel-release
Enable PowerTools
Next, enable the PowerTools with the command below:
sudo dnf config-manager --set-enabled powertools
Install Remi Repository
At this point, you can install the Remi repository on Rocky Linux 8 with the following command:
sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Now you can verify all the repositories added are active with the commands below:
# sudo dnf -y makecache
# sudo dnf -y repolist

List Available PHP Versions
At this point, you can check the PHP modules on Rocky Linux 8:
sudo dnf module list php

As you can see the latest version available for PHP is PHP 8.2. To install it on your Rocky Linux 8, follow the steps below.
First, reset the PHP default module in the AppStream repository:
sudo dnf -y module reset php
Enable Remi PHP 8.2
Then, enable the Remi repository for PHP 8.2 on Rocky Linux 8 with the command below:
sudo dnf module install php:remi-8.2
When you are finished, you can verify your PHP installation by checking its version:
php --version

If you would like to install the most commonly used extensions for PHP 8.2, use the following command:
sudo dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imap php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml php-dom php-redis php-memcached php-memcache
Configure PHP-FPM Service
By default on Rocky Linux 8, the PHP-FPM service is designed to be run by (Apache) user. If you are using Nginx you need to make configuration changes at (www.conf).
You can open the file with your favorite text editor, here we use vi:
sudo vi /etc/php-fpm.d/www.conf
Find the user and group directives and change them to Nginx as shown below:
user = nginx
group = nginx
When you are done, save and close the file.
Reload the PHP-FPM service to apply the changes:
sudo systemctl restart php-fpm
The Nginx server block needs the following example below for Nginx to process the PHP files.
Below is an example for all server {} blocks that process PHP files that need the location ~ .php$ added.
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;
}
For more information, you can visit the PHP Documentation page.
Conclusion
At this point, you have learned to Install PHP 8.2 on Rocky Linux 8. You just need to need to enable, epel repo, PowerTools, and Remi PHP 8.2. Then, you can easily install it on your Rocky Linux 8.
Hope you enjoy it. Please subscribe to us on Facebook and Twitter.
Also, you may like to read the following articles:
Install PowerDNS and PowerDNS-Admin on RockyLinux 8
Installing 7Zip on Rocky Linux 8
Installing Grafana Monitoring on Rocky Linux 9
Install PHP ionCube Loader on Rocky Linux 8
Enable Flatpak on Rocky Linux 8
FAQs
What prerequisites are needed before installing PHP 8.2 on Rocky Linux 8?
You’ll need to enable the EPEL and Remi repositories, which provide the necessary PHP 8.2 packages.
How to install PHP 8.2 and its common extensions on Rocky Linux 8?
After enabling the required repositories, you can run the command below:sudo dnf install php php-cli php-gd php-curl php-zip php-mbstring
How to check the PHP version on Rocky Linux 8?
You can use the following command: php --version