Learn how to install a LAMP stack on Rocky Linux 10 with Apache, MariaDB, and PHP. Follow this step by step guide to prepare your server for WordPress, Laravel, and other PHP applications.
Rocky Linux has become a popular choice for developers, system administrators, and businesses looking for a stable enterprise operating system. Built as a community driven replacement for CentOS, Rocky Linux provides long term support, strong security updates, and full compatibility with Red Hat Enterprise Linux.
For many server deployments, one of the first tasks after provisioning a new system is setting up a web hosting environment. Whether you're deploying WordPress, Laravel, Magento, Drupal, or a custom PHP application, you'll need a web server, database server, and PHP runtime working together.
This combination is known as a LAMP stack, which stands for Linux, Apache, MariaDB, and PHP. These technologies have powered websites and web applications for decades and remain one of the most trusted hosting environments available today.
In this guide, we'll install Apache, MariaDB, and PHP on Rocky Linux 10, verify that each service is operating correctly, and prepare the server for hosting modern PHP based applications.
Prerequisites
Before starting, make sure you have:
- An AlmaLinux 10 dedicated server.
- Root access or a sudo enabled user
- A stable internet connection
Connect to your server via SSH:
ssh username@server-ip
Replace username and server-ip with your actual server details.
Step 1: Update System Packages
Before installing new software, update the system packages to ensure everything is current.
Run:
sudo dnf update -y
This command downloads and installs the latest available updates from Rocky Linux repositories.
Step 2: Install Apache HTTP Server
Apache is one of the most widely deployed web servers and remains a dependable option for hosting websites and applications.
Install Apache:
sudo dnf install httpd -y
Enable and start the service:
sudo systemctl enable --now httpd
Verify the service status:
sudo systemctl status httpd
You should see that the service is active and running.
Step 3: Configure Firewall Access
Rocky Linux uses firewalld by default. To allow visitors to access your website, you'll need to open HTTP and HTTPS ports.
Allow HTTP traffic:
sudo firewall-cmd --permanent --add-service=http
Allow HTTPS traffic:
sudo firewall-cmd --permanent --add-service=https
Reload the firewall:
sudo firewall-cmd --reload
Verify active rules:
sudo firewall-cmd --list-services
You should see both http and https listed.
Step 4: Verify Apache Installation
Open a browser and visit:
http://your-server-ip
If Apache is installed correctly, you'll see the default Rocky Linux Apache test page.
This confirms the web server is responding to requests successfully.
Step 5: Install MariaDB
MariaDB is responsible for storing application data, user accounts, settings, and content for websites and web applications.
Install MariaDB Server:
sudo dnf install mariadb-server -y
Enable and start the database service:
sudo systemctl enable --now mariadb
Check the service status:
sudo systemctl status mariadb
Step 6: Install PHP
PHP powers popular applications such as WordPress, Laravel, Magento, Drupal, and many others.
Install PHP and commonly used extensions:
sudo dnf install php php-cli php-common php-mysqlnd php-curl php-gd php-mbstring php-xml php-zip php-intl php-bcmath -y
Verify the installed PHP version:
php -v
Example output:
PHP 8.3.29 (cli) (built: Dec 16 2025 14:32:42) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.3.29, Copyright (c) Zend Technologies
with Zend OPcache v8.3.29, Copyright (c), by Zend Technologies
The exact version may vary depending on the latest packages available in AlmaLinux repositories.
Step 7: Test PHP Processing
Create a PHP test file:
sudo nano /var/www/html/info.php
Add:
<?php
phpinfo();
?>
Save and exit.
Open:
http://your-server-ip/info.php
If PHP is configured correctly, you'll see the PHP information page.
After testing, remove the file:
sudo rm -f /var/www/html/info.php
Step 8: Verify Database Connectivity
Access MariaDB:
sudo mariadb
Check the installed version:
SELECT VERSION();
Example output:
+------------------+
| VERSION() |
+------------------+
| 10.11.15-MariaDB |
+------------------+
1 row in set (0.000 sec)
Exit the database:
EXIT;
Common Service Management Commands
Start Apache:
sudo systemctl start httpd
Stop Apache:
sudo systemctl stop httpd
Restart Apache:
sudo systemctl restart httpd
Check Apache status:
sudo systemctl status httpd
Start MariaDB:
sudo systemctl start mariadb
Restart MariaDB:
sudo systemctl restart mariadb
Check MariaDB status:
sudo systemctl status mariadb
Final Thoughts
Rocky Linux 10 provides a stable and enterprise ready platform for hosting modern web applications. By combining Apache, MariaDB, and PHP, you've built a proven web hosting environment capable of supporting everything from personal projects to production workloads.
With your LAMP stack now installed, you're ready to deploy WordPress, Laravel, Magento, Drupal, and other PHP based applications on your Rocky Linux server.

