PHP is a widely-used open-source programming language to create dynamic websites such as blogs, forums, e-commerce, etc. It was originally created by Rasmus Lerdorf in 1994.
CentOS 7 comes with PHP 5.x by default, which is already the end of life.
In this post, we will see how to install PHP 8.0 on CentOS 7 / RHEL 7.
Install PHP 8.0 On CentOS 7 / RHEL 7
Add Remi Repository
Remi is a third-party repository that provides the latest PHP rpm packages for RHEL / CentOS.
To enable the Remi repository, install the Remi repository auto-configuration package.
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
Install PHP 8.0
Use the below command to install PHP 8.0 package by temporarily enabling the Remi PHP 8.0 repository.
yum install -y --enablerepo=remi-php80 php php-cli
Enable Remi PHP 8.0 repository permanently with
yum-config-manager command and then install PHP v8.0.
yum install -y yum-utils yum-config-manager --enable remi-php80 yum install -y php php-cli
Check PHP Version
Once you have installed the PHP package, check the PHP version with the following command.
PHP 8.0.0 (cli) (built: Nov 24 2020 17:04:03) ( NTS gcc x86_64 ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
Install PHP Extensions
PHP extensions are compiled libraries that enable support for your code. For example, installing PHP MySQL extension will enable your PHP code to connect with the MySQL database.
To install MySQL support, you can install the php-mysqlnd package.
yum install -y --enablerepo=remi-php80 php-mysqlnd OR yum install -y php-mysqlnd
Once you have installed a particular extension, you can use the below command to verify it.
php -m | grep -i mysql
mysqli mysqlnd pdo_mysql
That’s All. Please share your feedback in the comments section.