How to Install PHP 8.1 on CentOS 7

How to Install PHP 8.1 on CentOS 7

Install PHP 8.1 on CentOS 7

PHP is used in all over the world. It is one of the famous server-side scripting languages which is used to develop dynamic web pages. Today, The latest version of PHP is 8.1 which offers a variety of new features.

PHP plays an important part in both Frontend and Backend of the Website. In this tutorial, we will learn, how we can download and install PHP 8.1 in CentOS 7.

Read Also: How to Install and Use PHP Composer on CentOS 7 and 8

PHP Modules

PHP Modules are also plays an important role in PHP. These modules create the configuration between different packages.

xml
ldap
mysqli
curl
imap
zip
json
opcache
intl
mbstring
gd
mysqlnd

Enable REMI Repository

To install PHP 8.1 on CentOS 7, We need to add the necessary repository. These repositories store different packages version by version, which help us to install required packages with their dependencies.

  • Run the following command to enable the REMI repository on the CentOS 7.
yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm

Install PHP 8.1 on CentOS

  • Run the following command to install PHP 8.1 with some important PHP extensions.
sudo yum install php81 php81-php-intl php81-php-mbstring php81-php-gd php81-php-xml php81-php-imap php81-php-zip php81-php-curl php81-php-json php81-php-ldap php81-php-mysqlnd php81-php-opcache -y
  • After installation, you can check the PHP version with the following command.
php -v
  • After installation, If the above command show an error that the command not found. In that case, you need to set PHP 8.1 as the default PHP version. To set the default PHP version for a session, run the following command.
scl enable php81 bash
  • To check the installed PHP modules. Run the following command.
php -m
  • If you have multiple PHP version installed on the server, and you want to check the installed version. Run the following command to check installed PHP versions.
yum list installed | grep php

Conclusion

In this tutorial, we have learned how to install PHP 8.1 on the CentOS 7 with their respective modules. PHP is one of mostly used open-source server-side scripting language which is used by many devs in web development. PHP is also used to develop lots of projects, including GUIs (Graphical User Interfaces)

If you guys have any queries related to this tutorial, then let me know in the comments sections.