How to Install a LAMP Server on Rocky Linux

LAMP server on Rocky Linux

Hey there! Some links on this page may be affiliate links which means that, if you choose to make a purchase, I may earn a small commission at no extra cost to you. I greatly appreciate your support!

In this tutorial, learn how to set up a LAMP (Linux, Apache, MariaDB, and PHP) server on Rocky Linux.

Prerequisites:

Please note that a complete video tutorial is available at the end of this tutorial.

1. Update Rocky Linux

It’s always good practice to update your system before installing any new packages.

dnf upgrade

2. Install Apache Web Server

Install the Apache web server, start it up, and enable it to automatically startup at boot with the following commands.

dnf install httpd 
systemctl start httpd
systemctl status httpd
systemctl enable httpd

At this point, you can go to the IP address of your web browser and see the default Apache landing page for Rocky Linux.

Apache default landing page on Rocky Linux

The source for this page exists at /usr/share/httpd/noindex/index.html.

3. Install PHP

While you can install any version of PHP that Rocky Linux supports, this tutorial will show you how to install PHP 7.4.

dnf module list php 
dnf module enable php:7.4
dnf install php

Check the version of PHP that is installed.

php -v

Start up PHP-FPM and enable it to automatically start at system boot.

systemctl start php-fpm 
systemctl status php-fpm
systemctl enable php-fpm
systemctl restart httpd php-fpm

4. Install MariaDB

Install the database, start it up, and enable it to automatically start at system boom.

dnf install mariadb-server
systemctl start mariadb
systemctl status mariadb
systemctl enable mariadb

Secure the MariaDB installation by setting a root password. Answer Y to all prompts.

mysql_secure_installation

The database command prompt is accessible with this command. Please provide the password that you just created in the previous step.

mysql -u root -p

YouTube video

Next Steps

From here, you can create the website of your choice including WordPress on Rocky Linux.

Facebook
Twitter
Pinterest
LinkedIn
Reddit

Meet Tony

Tony from Tony Teaches Tech headshot

With a strong software engineering background, Tony is determined to demystify the web. Discover why Tony quit his job to pursue this mission. You can join the Tony Teaches Tech community here.

Leave a Reply

Your email address will not be published. Required fields are marked *