Rocky Linux 9 is a popular Linux distribution commonly used for web servers. PHP, a widely-used scripting language, is a crucial component for many web applications. In this tutorial, we will guide you through the process of installing PHP 8.2 on your Rocky Linux 9 system. With the latest version of PHP, you can take advantage of new features, performance improvements, and security enhancements. Let’s get started!
Prerequisites
Before we begin the installation process, make sure you have the following:
- A system with Rocky Linux 9 installed and running.
- Root access to the system.
Adding EPEL and REMI Repositories
To install PHP 8.2, we need to add and enable the Remi RPM repositories, which contain the necessary PHP 8.2 packages. Follow these steps to add the repositories:
- Open a terminal window and log in to your Rocky Linux 9 system as the root user.
- Install the EPEL repository by running the following command:
dnf install epel-release
- Next, install the Remi repository by executing the following command:
dnf install http://rpms.remirepo.net/enterprise/remi-release-9.rpm
Installing DNF Utilities
Before proceeding with the PHP 8.2 installation, let’s install the DNF utilities to manage packages effectively. Run the following command:
dnf install dnf-utils
Enabling PHP 8.2 Remi Repository
To enable the PHP 8.2 Remi repository, run the following commands:
dnf module reset php dnf module install php:remi-8.2
Installing PHP 8.2
Now that we have added the necessary repositories and enabled the PHP 8.2 Remi repository, we can proceed with the installation. Run the following command to install PHP 8.2:
dnf install php
Verifying the PHP Installation
To verify that PHP 8.2 has been successfully installed, you can check the version by running the following command:
php -v
If everything was installed correctly, you should see the PHP version information displayed on your screen, similar to the following:
PHP 8.2.0 (cli) (built: Dec 6 2022 14:26:47) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
with Zend OPcache v8.2.0, Copyright (c) Zend Technologies
Congratulations! You have successfully installed PHP 8.2 on your Rocky Linux 9 system.
Installing Additional PHP Modules
When working with CMS applications like WordPress, Drupal, or Joomla, you may need to install additional PHP modules. To install the required modules, use the following command:
dnf -y install php-{cli,gd,mysqlnd,mbstring,json,common,dba,dbg,devel,embedded,enchant,bcmath,gmp,intl,ldap,odbc,pdo,opcache,pear,pgsql,process,snmp,soap,xml,opcache}
This command installs a variety of modules commonly used by CMS applications, ensuring that your PHP installation is compatible with these platforms.
Conclusion
In this tutorial, we walked you through the process of installing PHP 8.2 on Rocky Linux 9. By adding the necessary repositories, enabling the PHP 8.2 Remi repository, and installing PHP, you can take advantage of the latest features and improvements in PHP. Additionally, we covered how to verify the installation and install additional PHP modules for CMS applications.
Now that you have PHP 8.2 up and running, you can start developing and deploying your web applications with confidence. If you encounter any issues or have further questions, don’t hesitate to consult the official documentation or seek assistance from the Rocky Linux community.
Remember, Shape.host offers reliable and scalable Linux SSD VPS hosting solutions, including support for PHP 8.2. If you’re looking for a hosting provider that combines performance, security, and excellent customer service, consider Shape.host for your PHP-powered applications.