How To Install Apache v2.4.37, MariaDB 10.6 and PHP 8.1 on Rocky Linux 8.5

DigitalOcean Referral Badge
Start your VPS now with FREE $100 credit.

Rocky Linux is a free, open-source, enterprise ready operating system based on Red Hat Enterprise Linux source code. It’s designed as CentOS successor which have been killed of by Red Hat last year. So, if you are currently searching for Linux-based enterprise operating system you can stick to Rocky Linux OS.

Well, today we will guide you step by step on how to install Apache, MariaDB, and PHP 8.1 on Rocky Linux 8.5 (or commonly known as LAMP Stack in the web hosting industry). We will use cheap $5 droplet from Digital Ocean to deploy LAMP stack for development only. So, before moving into the installation step, make sure to meet the following requirenments.

PRE-REQUISITES:

* VPS, Cloud, or Bare-Metal Server
* Running on Rocky Linux OS 8.5
* Server IPv4 Address
* Superuser Privileges (Sudo Access)
* Gnome Terminal for Linux Desktop
* PuTTy SSH Client for Windows or Mac
* Powershell for Windows 10/11

1.) Perform System Update

On the first step don’t forget to perform system update in order to get the latest stable available packages and software from the official OS vendor. Stay calm, you can use either “yum” or even “dnf” commands on modern operating system based on RHEL source code.

A.) Login to your VM via SSH terminal

$ ssh [email protected]
[email protected]'s password:

B.) Then perform system update

$ dnf update

DigitalOcean Agent 101 kB/s | 3.3 kB 00:00
DigitalOcean Droplet Agent 75 kB/s | 3.3 kB 00:00
Dependencies resolved.
================================================================================
Package Arch Version Repo Size
================================================================================
Installing:
kernel x86_64 4.18.0-348.23.1.el8_5 baseos 7.0 M
Upgrading:
NetworkManager x86_64 1:1.32.10-5.el8_5 baseos 2.6 M
NetworkManager-libnm x86_64 1:1.32.10-5.el8_5 baseos 1.8 M
NetworkManager-team x86_64 1:1.32.10-5.el8_5 baseos 148 k
NetworkManager-tui x86_64 1:1.32.10-5.el8_5 baseos 335 k
cloud-init noarch 21.1-7.el8_5.5 appstream 1.1 M
cockpit-bridge x86_64 251.3-1.el8_5 baseos 538 k
cockpit-system noarch 251.3-1.el8_5 baseos 3.2 M
cockpit-ws x86_64 251.3-1.el8_5 baseos 1.3 M
cryptsetup-libs x86_64 2.3.3-4.el8_5.1 baseos 473 k
cyrus-sasl-lib x86_64 2.1.27-6.el8_5 baseos 122 k
device-mapper x86_64 8:1.02.177-11.el8_5 baseos 376 k
device-mapper-libs x86_64 8:1.02.177-11.el8_5 baseos 408 k
dnf-plugins-core noarch 4.0.21-4.el8_5 baseos 69 k
expat x86_64 2.2.5-4.el8_5.3 baseos 112 k
glibc x86_64 2.28-164.el8_5.3 baseos 3.6 M
glibc-all-langpacks x86_64 2.28-164.el8_5.3 baseos 25 M
glibc-common x86_64 2.28-164.el8_5.3 baseos 1.3 M
gzip x86_64 1.9-13.el8_5 baseos 166 k
kernel-tools x86_64 4.18.0-348.23.1.el8_5 baseos 7.2 M
kernel-tools-libs x86_64 4.18.0-348.23.1.el8_5 baseos 7.0 M
kexec-tools x86_64 2.0.20-57.el8_5.1 baseos 513 k

2.) Install Apache v2.4.37 Web Server

Next, we can continue to the next step to install Apache 2.4 web server. We can use default Rocky Linux repository to install Apache.

$ dnf install httpd httpd-tools

Last metadata expiration check: 0:00:44 ago on Sat 30 Apr 2022 05:34:59 PM UTC.
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
httpd x86_64 2.4.37-43.module+el8.5.0+747+83fae388.3 appstream 1.4 M
httpd-tools x86_64 2.4.37-43.module+el8.5.0+747+83fae388.3 appstream 106 k
Installing dependencies:
apr x86_64 1.6.3-12.el8 appstream 128 k
apr-util x86_64 1.6.1-6.el8.1 appstream 104 k
httpd-filesystem noarch 2.4.37-43.module+el8.5.0+747+83fae388.3 appstream 39 k
mailcap noarch 2.1.48-3.el8 baseos 38 k
mod_http2 x86_64 1.15.7-3.module+el8.5.0+695+1fa8055e appstream 153 k
rocky-logos-httpd noarch 85.0-3.el8 baseos 22 k
Installing weak dependencies:
apr-util-bdb x86_64 1.6.1-6.el8.1 appstream 23 k
apr-util-openssl x86_64 1.6.1-6.el8.1 appstream 26 k
Enabling module streams:
httpd 2.4

Transaction Summary
=====================================================================================================================================================
Install 10 Packages

Total download size: 2.0 M
Installed size: 5.5 M
Is this ok [y/N]: y

Simply press y and this will install Apache 2.4.37-43 on your Rocky Linux machine. Then verify the Apache version using the following command.

$ httpd -v

Server version: Apache/2.4.37 (rocky)
Server built: Mar 24 2022 17:33:25
[root@open-source ~]# httpd -V
Server version: Apache/2.4.37 (rocky)
Server built: Mar 24 2022 17:33:25
Server's Module Magic Number: 20120211:83
Server loaded: APR 1.6.3, APR-UTIL 1.6.1
Compiled using: APR 1.6.3, APR-UTIL 1.6.1
Architecture: 64-bit
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

3.) Enable, Start, Stop, Restart and Check Status of Apache Service

You can use the following available commands to manage your Apache web server on Rocky Linux 8.5.

To Enable Apache Service start from boot

$ systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

To Start Apache Service

$ systemctl start httpd

To Stop Apache Service

$ systemctl stop httpd

To Restart Apache Service

$ systemctl restart httpd

To Check Status of Apache Service

$ systemctl status httpd

● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2022-04-30 17:39:58 UTC; 6s ago
Docs: man:httpd.service(8)
Main PID: 66582 (httpd)
Status: "Started, listening on: port 80"
Tasks: 213 (limit: 4730)
Memory: 24.1M
CGroup: /system.slice/httpd.service
├─66582 /usr/sbin/httpd -DFOREGROUND
├─66583 /usr/sbin/httpd -DFOREGROUND
├─66584 /usr/sbin/httpd -DFOREGROUND
├─66585 /usr/sbin/httpd -DFOREGROUND
└─66586 /usr/sbin/httpd -DFOREGROUND

Apr 30 17:39:58 open-source.project systemd[1]: Starting The Apache HTTP Server...
Apr 30 17:39:58 open-source.project systemd[1]: Started The Apache HTTP Server.
Apr 30 17:39:58 open-source.project httpd[66582]: Server configured, listening on: port 80

4.) Install MariaDB v10.6 Database Server

Next, let’s adding the MariaDB 10.6 repository into your Rocky machine. Currently MariaDB 10.6 is the latest stable release with long-term support until July 2026. The latest GA release of MariaDB 10.6 was introduced in July 2021. So, it’s strongly recommended to use MariaDB 10.6 on production environment.

READ:  How To Update Apache 2.4 Web Server (HTTPD) on VestaCP CentOS 7

We can use Red Hat EL 8.5 (x86_64 archietecture) repository to install MariaDB 10.6 database server on Rocky Linux 8.5, as you can on the following screenshots. Simply create a file called “MariaDB.repo” under directory of /etc/yum.repos.d.

$ nano /etc/yum.repos.d/MariaDB.repo
------------------------------------------------------------------------

# MariaDB 10.6 RedHat repository list - created UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://atl.mirrors.knownhost.com/mariadb/yum/10.6/rhel8-amd64
module_hotfixes=1
gpgkey=https://atl.mirrors.knownhost.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
------------------------------------------------------------------------
Setting up MariaDB 10.6 on Rocky Linux 8.5 using Red Hat EL 8 Repository
Setting up MariaDB 10.6 on Rocky Linux 8.5 using Red Hat EL 8 Repository

Then let’s install MariaDB using the following command. Simply press y to continue on installing MariaDB 10.6 database server.

$ dnf install MariaDB-server

MariaDB 1.9 MB/s | 584 kB 00:00
DigitalOcean Agent 124 kB/s | 3.3 kB 00:00
DigitalOcean Droplet Agent 52 kB/s | 3.3 kB 00:00
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
MariaDB-server x86_64 10.6.7-1.el8 mariadb 25 M
Installing dependencies:
MariaDB-client x86_64 10.6.7-1.el8 mariadb 14 M
MariaDB-common x86_64 10.6.7-1.el8 mariadb 88 k
MariaDB-shared x86_64 10.6.7-1.el8 mariadb 116 k
boost-program-options x86_64 1.66.0-10.el8 appstream 140 k
galera-4 x86_64 26.4.11-1.el8 mariadb 13 M
libaio x86_64 0.3.112-1.el8 baseos 31 k
libpmem x86_64 1.6.1-1.el8 appstream 78 k
lsof x86_64 4.93.2-1.el8 baseos 252 k
perl-Carp noarch 1.42-396.el8 baseos 29 k
perl-DBI x86_64 1.641-3.module+el8.4.0+509+59a8d9b3 appstream 739 k
perl-Data-Dumper x86_64 2.167-399.el8 baseos 57 k
perl-Digest noarch 1.17-395.el8 appstream 26 k
perl-Digest-MD5 x86_64 2.55-396.el8 appstream 36 k
perl-Encode x86_64 4:2.97-3.el8 baseos 1.5 M
perl-Errno x86_64 1.28-420.el8 baseos 75 k
perl-Exporter noarch 5.72-396.el8 baseos 33 k
perl-File-Path noarch 2.15-2.el8 baseos 37 k
perl-File-Temp noarch 0.230.600-1.el8 baseos 62 k
perl-Getopt-Long noarch 1:2.50-4.el8 baseos 62 k
perl-HTTP-Tiny noarch 0.074-1.el8 baseos 57 k
perl-IO x86_64 1.38-420.el8 baseos 141 k
perl-MIME-Base64 x86_64 3.15-396.el8 baseos 30 k
perl-Math-BigInt noarch 1:1.9998.11-7.el8 baseos 194 k
perl-Math-Complex noarch 1.59-420.el8 baseos 107 k
perl-Net-SSLeay x86_64 1.88-1.module+el8.4.0+512+d4f0fc54 appstream 378 k
perl-PathTools x86_64 3.74-1.el8 baseos 89 k
perl-Pod-Escapes noarch 1:1.07-395.el8 baseos 19 k
perl-Pod-Perldoc noarch 3.28-396.el8 baseos 85 k
perl-Pod-Simple noarch 1:3.35-395.el8 baseos 212 k
perl-Pod-Usage noarch 4:1.69-395.el8 baseos 33 k
perl-Scalar-List-Utils x86_64 3:1.49-2.el8 baseos 67 k
perl-Socket x86_64 4:2.027-3.el8 baseos 58 k
perl-Storable x86_64 1:3.11-3.el8 baseos 97 k
perl-Term-ANSIColor noarch 4.06-396.el8 baseos 45 k
perl-Term-Cap noarch 1.17-395.el8 baseos 22 k
perl-Text-ParseWords noarch 3.30-395.el8 baseos 17 k
perl-Text-Tabs+Wrap noarch 2013.0523-395.el8 baseos 23 k
perl-Time-Local noarch 1:1.280-1.el8 baseos 32 k
perl-URI noarch 1.73-3.el8 appstream 115 k
perl-Unicode-Normalize x86_64 1.25-396.el8 baseos 81 k
perl-constant noarch 1.33-396.el8 baseos 24 k
perl-interpreter x86_64 4:5.26.3-420.el8 baseos 6.3 M
perl-libnet noarch 3.11-3.el8 appstream 120 k
perl-libs x86_64 4:5.26.3-420.el8 baseos 1.6 M
perl-macros x86_64 4:5.26.3-420.el8 baseos 71 k
perl-parent noarch 1:0.237-1.el8 baseos 19 k
perl-podlators noarch 4.11-1.el8 baseos 117 k
perl-threads x86_64 1:2.21-2.el8 baseos 60 k
perl-threads-shared x86_64 1.58-2.el8 baseos 47 k
socat x86_64 1.7.4.1-1.el8 appstream 322 k
Installing weak dependencies:
perl-IO-Socket-IP noarch 0.39-5.el8 appstream 46 k
perl-IO-Socket-SSL noarch 2.066-4.module+el8.4.0+512+d4f0fc54 appstream 297 k
perl-Mozilla-CA noarch 20160104-7.module+el8.4.0+529+e3b3e624 appstream 14 k
Enabling module streams:
perl 5.26
perl-DBI 1.641
perl-IO-Socket-SSL 2.066
perl-libwww-perl 6.34

Transaction Summary
=====================================================================================================================================================
Install 54 Packages

Total download size: 67 M
Installed size: 298 M
Is this ok [y/N]: y

Verify the version installed using the following command.

$ mysql -V
mysql Ver 15.1 Distrib 10.6.7-MariaDB, for Linux (x86_64) using readline 5.1

5.) Command to Manage MariaDB Database Server

You can use the following available commands to manage your MariaDB v10.6 database server on your virtual machine.

To Enable MariaDB Service start from boot

$ systemctl enable mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

To Start MariaDB Service

$ systemctl start mariadb

To Stop MariaDB Service

$ systemctl stop mariadb

To Restart MariaDB Service

$ systemctl restart mariadb

To Check Status of MariaDB Service

$ systemctl status mariadb

Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Sat 2022-04-30 17:55:40 UTC; 6s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 70087 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 70065 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]>
Process: 70063 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 70075 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 12 (limit: 4730)
Memory: 55.1M
CGroup: /system.slice/mariadb.service
└─70075 /usr/sbin/mariadbd

Apr 30 17:55:40 open-source.project mariadbd[70075]: 2022-04-30 17:55:40 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
Apr 30 17:55:40 open-source.project mariadbd[70075]: 2022-04-30 17:55:40 0 [Note] InnoDB: 10.6.7 started; log sequence number 42331; transaction id >
Apr 30 17:55:40 open-source.project mariadbd[70075]: 2022-04-30 17:55:40 0 [Note] Plugin 'FEEDBACK' is disabled.
Apr 30 17:55:40 open-source.project mariadbd[70075]: 2022-04-30 17:55:40 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Apr 30 17:55:40 open-source.project mariadbd[70075]: 2022-04-30 17:55:40 0 [Note] Server socket created on IP: '0.0.0.0'.
Apr 30 17:55:40 open-source.project mariadbd[70075]: 2022-04-30 17:55:40 0 [Note] Server socket created on IP: '::'.
Apr 30 17:55:40 open-source.project mariadbd[70075]: 2022-04-30 17:55:40 0 [Note] InnoDB: Buffer pool(s) load completed at 220430 17:55:40
Apr 30 17:55:40 open-source.project mariadbd[70075]: 2022-04-30 17:55:40 0 [Note] /usr/sbin/mariadbd: ready for connections.
Apr 30 17:55:40 open-source.project mariadbd[70075]: Version: '10.6.7-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
Apr 30 17:55:40 open-source.project systemd[1]: Started MariaDB 10.6.7 database server.

6.) Securing MariaDB Environments

After that don’t forget to securing your MariaDB database server environments using the following commands. Don’t forget to set the MariaDB root password during Securing MariaDB Environments. Since we haven’t set the correct root password for MariaDB administrative account on the previous installation step.

READ:  How To Install CSF & LFD Firewall on Rocky Linux 8.5

PLEASE NOTE: Started from MariaDB 10.4.6, mariadb-secure-installation is a symlink to mysql_secure_installation. While mariadb-secure-installation is a binary name of mysql_secure_installation (as symlink of it) started from MariaDB version 10.5.2. So we should use mariadb-secure-installation to perform securing environments for MariaDB 10.6 database server.

$ mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): "SIMPLY PRESS ENTER ON THIS STEP"
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password: "NEW MARIADB ROOT PASSWORD HERE"
Re-enter new password: "NEW MARIADB ROOT PASSWORD HERE"
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@open-source ~]#

7.) Add EPEL and Remi’s RPM Repositories

You can install PHP 8.1 along with its PHP extensions and PHP modules using REMI and EPEL repositories (Extra Packages for Enterprise Linux). It can be applied for all RHEL-based operating system like CentOS, Rocky Linux, Oracle Linux, and AlmaLinux OS. Simply run the following command to add EPEL and Remi’s RPM repositories into your system.

$ dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
DigitalOcean Agent 93 kB/s | 3.3 kB 00:00
DigitalOcean Droplet Agent 86 kB/s | 3.3 kB 00:00
remi-release-8.rpm 92 kB/s | 29 kB 00:00
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
remi-release noarch 8.5-3.el8.remi @commandline 29 k
Installing dependencies:
epel-release noarch 8-13.el8 extras 23 k

Transaction Summary
=====================================================================================================================================================
Install 2 Packages

Total size: 52 k
Total download size: 23 k
Installed size: 59 k
Is this ok [y/N]: y
$ rpm -qa | grep remi
remi-release-8.5-3.el8.remi.noarch
$ rpm -qa | grep epel
epel-release-8-13.el8.noarch

8.) Install PHP 8.1

PHP 8.1 is the current latest stable release of PHP Branch which have active support until 25 November 2023 and security support until 25 November 2024. So, it’s highly-recomended to use the latest stable version of PHP 8.1 in order to get all benefits like bug fixes, new features, improvement and security patch from the latest PHP Branch.

A.) Check available PHP version on your Rocky machine using the following command.

$ dnf module list php
DigitalOcean Agent 108 kB/s | 3.3 kB 00:00
DigitalOcean Droplet Agent 91 kB/s | 3.3 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 3.0 MB/s | 11 MB 00:03
Extra Packages for Enterprise Linux Modular 8 - x86_64 555 kB/s | 1.0 MB 00:01
Remi's Modular repository for Enterprise Linux 8 - x86_64 1.1 kB/s | 833 B 00:00
Remi's Modular repository for Enterprise Linux 8 - x86_64 2.9 MB/s | 3.1 kB 00:00
Importing GPG key 0x5F11735A:
Userid : "Remi's RPM repository <[email protected]>"
Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Is this ok [y/N]: y
Remi's Modular repository for Enterprise Linux 8 - x86_64 1.1 MB/s | 976 kB 00:00
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 1.6 kB/s | 833 B 00:00
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 3.0 MB/s | 3.1 kB 00:00
Importing GPG key 0x5F11735A:
Userid : "Remi's RPM repository <[email protected]>"
Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Is this ok [y/N]: y
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 2.2 MB/s | 2.1 MB 00:00
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
php 7.2 [d] common [d], devel, minimal PHP scripting language
php 7.3 common [d], devel, minimal PHP scripting language
php 7.4 common [d], devel, minimal PHP scripting language

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name Stream Profiles Summary
php remi-7.2 common [d], devel, minimal PHP scripting language
php remi-7.3 common [d], devel, minimal PHP scripting language
php remi-7.4 common [d], devel, minimal PHP scripting language
php remi-8.0 common [d], devel, minimal PHP scripting language
php remi-8.1 common [d], devel, minimal PHP scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[root@open-source ~]#

B.) Enable REMI PHP 8.1

Run the following command to enable REMI PHP 8.1 on your Rocky Linux. After that, we can perform PHP 8.1 installation on your virtual machine.

$ dnf module enable php:remi-8.1
Last metadata expiration check: 0:02:17 ago on Sat 30 Apr 2022 06:30:42 PM UTC.
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Enabling module streams:
php remi-8.1

Transaction Summary
=====================================================================================================================================================

Is this ok [y/N]: y
Complete!

To install PHP 8.1 with its PHP extensions and PHP modules, simply run these simple commands.

$ dnf install php php-bcmath php-cli php-common php-gd php-imap php-mbstring php-mcrypt php-mysql php-mysqlnd php-pdo php-soap php-tidy php-xml php-xmlrpc php-opcache php-redis php-pecl-mcrypt php-brotli
Last metadata expiration check: 0:02:37 ago on Sat 30 Apr 2022 06:30:42 PM UTC.
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
php x86_64 8.1.5-1.el8.remi remi-modular 1.7 M
php-bcmath x86_64 8.1.5-1.el8.remi remi-modular 88 k
php-brotli x86_64 0.13.1-1.el8.remi.8.1 remi-modular 30 k
php-cli x86_64 8.1.5-1.el8.remi remi-modular 5.3 M
php-common x86_64 8.1.5-1.el8.remi remi-modular 1.2 M
php-gd x86_64 8.1.5-1.el8.remi remi-modular 104 k
php-imap x86_64 8.1.5-1.el8.remi remi-modular 109 k
php-mbstring x86_64 8.1.5-1.el8.remi remi-modular 521 k
php-mysqlnd x86_64 8.1.5-1.el8.remi remi-modular 254 k
php-opcache x86_64 8.1.5-1.el8.remi remi-modular 628 k
php-pdo x86_64 8.1.5-1.el8.remi remi-modular 161 k
php-pecl-mcrypt x86_64 1.0.4-5.el8.remi.8.1 remi-modular 34 k
php-pecl-mysql x86_64 1.0.0-0.25.20210423.ca514c4.el8.remi.8.1 remi-modular 43 k
php-pecl-redis5 x86_64 5.3.7-1.el8.remi.8.1 remi-modular 270 k
php-pecl-xmlrpc x86_64 1.0.0~rc3-1.el8.remi.8.1 remi-modular 62 k
php-soap x86_64 8.1.5-1.el8.remi remi-modular 232 k
php-tidy x86_64 8.1.5-1.el8.remi remi-modular 85 k
php-xml x86_64 8.1.5-1.el8.remi remi-modular 251 k
Installing dependencies:
fribidi x86_64 1.0.4-8.el8 appstream 88 k
gd3php x86_64 2.3.3-4.el8.remi remi-safe 146 k
graphite2 x86_64 1.3.10-10.el8 appstream 120 k
harfbuzz x86_64 1.7.5-3.el8 appstream 295 k
jbigkit-libs x86_64 2.1-14.el8 appstream 54 k
libXpm x86_64 3.5.12-8.el8 appstream 57 k
libc-client x86_64 2007f-24.el8 epel 564 k
libimagequant x86_64 2.12.5-1.el8 epel 63 k
libjpeg-turbo x86_64 1.5.3-12.el8 appstream 156 k
liblzf x86_64 3.6-16.el8 epel 28 k
libmcrypt x86_64 2.5.8-26.el8 epel 109 k
libraqm x86_64 0.7.0-4.el8 epel 19 k
libsodium x86_64 1.0.18-2.el8 epel 162 k
libtidy x86_64 5.6.0-5.el8 epel 227 k
libtiff x86_64 4.0.9-20.el8 appstream 187 k
libwebp x86_64 1.0.0-5.el8 appstream 271 k
libxslt x86_64 1.1.32-6.el8 baseos 249 k
oniguruma5php x86_64 6.9.7.1-1.el8.remi remi-safe 210 k
php-pecl-igbinary x86_64 3.2.7-1.el8.remi.8.1 remi-modular 203 k
php-pecl-msgpack x86_64 2.2.0~RC1-4.el8.remi.8.1 remi-modular 67 k
Installing weak dependencies:
nginx-filesystem noarch 1:1.14.1-9.module+el8.4.0+542+81547229 appstream 23 k
php-fpm x86_64 8.1.5-1.el8.remi remi-modular 1.8 M
php-sodium x86_64 8.1.5-1.el8.remi remi-modular 101 k
Enabling module streams:
nginx 1.14

Transaction Summary
=====================================================================================================================================================
Install 41 Packages

Total download size: 16 M
Installed size: 64 M
Is this ok [y/N]: y

C.) Verify Installed PHP Version

Next, you can verify installed PHP version using the following commands, to know that’s really PHP 8.1, not another PHP version.

$ php -v
PHP 8.1.5 (cli) (built: Apr 12 2022 16:19:58) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.5, Copyright (c) Zend Technologies
with Zend OPcache v8.1.5, Copyright (c), by Zend Technologies

CONCLUSIONS:

We have successfully in deploying LAMP Stack which include some common widely used packages to run web application over public internet like Apache HTTP web server, MariaDB, and PHP. Later on the next article we can continue to setting up and configure Apache virtual host to run simple website or blog.

Leave a Comment