How To Install php on Rocky Linux 8

In this tutorial we learn how to install php on Rocky Linux 8. php is PHP scripting language for creating dynamic web sites

Introduction

In this tutorial we learn how to install php on Rocky Linux 8.

What is php

PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers to write dynamically generated web pages. PHP also offers built-in database integration for several commercial and non-commercial database management systems, so writing a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding is probably as a replacement for CGI scripts. The php package contains the module (often referred to as mod_php) which adds support for the PHP language to Apache HTTP Server.

We can use yum or dnf to install php on Rocky Linux 8. In this tutorial we discuss both methods but you only need to choose one of method to install php.

Install php on Rocky Linux 8 Using dnf

Update yum database with dnf using the following command.

sudo dnf makecache --refresh

After updating yum database, We can install php using dnf by running the following command:

sudo dnf -y install php

Install php on Rocky Linux 8 Using yum

Update yum database with yum using the following command.

sudo yum makecache --refresh

After updating yum database, We can install php using yum by running the following command:

sudo yum -y install php

How To Uninstall php on Rocky Linux 8

To uninstall only the php package we can use the following command:

sudo dnf remove php

php Package Contents on Rocky Linux 8

/etc/httpd/conf.d/php.conf
/etc/httpd/conf.modules.d/15-php.conf
/usr/lib/.build-id
/usr/lib/.build-id/ab
/usr/lib/.build-id/ab/bc50fa62b34634abb9fee39484293fe4a0761e
/usr/lib64/httpd/modules/libphp7.so
/usr/share/httpd/icons/php.gif
/var/lib/php/opcache
/var/lib/php/session
/var/lib/php/wsdlcache

References

Summary

In this tutorial we learn how to install php on Rocky Linux 8 using yum and dnf.