How to Install LAMP Stack on Rocky Linux 10
A LAMP stack is a group of open-source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym that represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP.
Pre-requisites :
-
A system with Rocky Linux 10 installed and running.
root
access to the system.
Install Apache Web Server
First, we will start by installing the Apache web server. To complete the installation, use the following command.
dnf install httpd httpd-tools
Once the installation is complete, enable Apache (to start automatically upon system boot), start the web server and verify the status using the commands below.
systemctl enable httpd
systemctl start httpd
systemctl status httpd
Output:
[root@vps ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: di>
Drop-In: /etc/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Thu 2025-06-19 07:15:00 UTC; 3s ago
Invocation: 7fb53ef56865470d8a7e6ba1edb2136a
Docs: man:httpd.service(8)
Main PID: 283782 (httpd)
Status: "Started, listening on: port 80"
Tasks: 177 (limit: 35140)
Memory: 17.9M (peak: 18.3M)
CPU: 133ms
CGroup: /system.slice/httpd.service
├─283782 /usr/sbin/httpd -DFOREGROUND
├─283791 /usr/sbin/httpd -DFOREGROUND
To make your pages available to the public, you will have to edit your firewall rules to allow HTTP and HTTPS requests on your web server by using the following commands.
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
Output:
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@server ~]# firewall-cmd --reload
success
Verify that the web server is running and accessible by accessing your server’s IP address.
echo "Hello there, Apache webserver is now running" > /var/www/html/index.html
And restart the Web Server to reflect the changes made.
systemctl restart httpd
From your browser,
http://IP_address
Install PHP 8.4
Install PHP 8.4 on RockyLinux 10
This will help you to install PHP 8.4 on Rocky Linux 10 using EPEL and Remi repositories.
To begin, enable the CRB (CodeReady Builder) repository, which provides libraries required by some third-party packages,
dnf config-manager --set-enabled crb
Next, install the EPEL repository. This adds additional useful packages that aren't available in the default AlmaLinux repositories,
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm
Now, install the Remi repository, which maintains the latest PHP versions for RHEL-based systems,
dnf install https://rpms.remirepo.net/enterprise/remi-release-10.rpm
Switch the system's PHP module to Remi’s PHP 8.4 stream to ensure packages are pulled from the correct source,
dnf module switch-to php:remi-8.4
Enable and install the PHP 8.4 module,
dnf module install php:remi-8.4
Verify PHP Installation
Check the installed PHP version to confirm success,
php -v
Output:
[root@vps ~]# php -v
PHP 8.4.8 (cli) (built: Jun 3 2025 16:29:26) (NTS gcc x86_64)
Copyright (c) The PHP Group
Built by Remi's RPM repository <https://rpms.remirepo.net/> #StandWithUkraine
Zend Engine v4.4.8, Copyright (c) Zend Technologies
with Zend OPcache v8.4.8, Copyright (c), by Zend Technologies
Now restart your web server so that Apache knows that it will be serving PHP requests as well.
systemctl restart httpd
Install MariaDB Server
MariaDB is a popular database server. The installation is simple and requires just a few steps as shown.
dnf install mariadb-server mariadb
Output:
[root@vps ~]# dnf install mariadb-server mariadb
Last metadata expiration check: 0:03:17 ago on Thu 19 Jun 2025 07:20:00 AM UTC.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mariadb x86_64 3:10.11.11-1.el10 appstream 1.6 M
mariadb-server x86_64 3:10.11.11-1.el10 appstream 9.9 M
Installing dependencies:
checkpolicy x86_64 3.8-1.el10 appstream 357 k
libaio x86_64 0.3.111-22.el10 baseos 24 k
mariadb-common noarch 3:10.11.11-1.el10 appstream 35 k
mariadb-connector-c x86_64 3.4.4-1.el10 baseos 206 k
mariadb-connector-c-config noarch 3.4.4-1.el10 baseos 8.9 k
mariadb-errmsg noarch 3:10.11.11-1.el10 appstream 261 k
mysql-selinux noarch 1.0.13-2.el10 appstream 37 k
perl-DBD-MariaDB x86_64 1.23-10.el10 appstream 154 k
perl-DBI x86_64 1.643-26.el10 appstream 712 k
perl-File-Copy noarch 2.41-512.1.el10_0 appstream 20 k
perl-Math-BigInt noarch 1:2.0030.03-3.el10 appstream 231 k
perl-Math-Complex noarch 1.62-512.1.el10_0 appstream 46 k
perl-Sys-Hostname x86_64 1.25-512.1.el10_0 appstream 17 k
Once the installation is complete, enable MariaDB (to start automatically upon system boot), start the MariaDB, and verify the status using the commands below.
systemctl enable mariadb
systemctl start mariadb
systemctl status mariadb
Output:
[root@vps ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.11 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: >
Active: active (running) since Thu 2025-06-19 07:24:20 UTC; 5s ago
Invocation: e46ca12cb68e4e01a2e3ef8bb239c61b
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 286077 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited>
Process: 286100 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.se>
Process: 286203 ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exit>
Main PID: 286190 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 12 (limit: 35140)
Memory: 204.3M (peak: 230.5M)
CPU: 660ms
CGroup: /system.slice/mariadb.service
└─286190 /usr/libexec/mariadbd --basedir=/usr
Finally, you will want to secure your MariaDB installation by issuing the following command.
mysql_secure_installation
Output:
[root@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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
Once secured, you can connect to MySQL and review the existing databases on your database server by using the following command.
mysql -e "SHOW DATABASES;" -p
Output:
[root@server ~]# mysql -e "SHOW DATABASES;" -p
Enter password:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
Done!
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS