Learn how to install LAMP Stack on RHEL 8 with our comprehensive guide. Follow step-by-step instructions to set up and configure your LAMP Stack efficiently on your RHEL 8 system. #centlinux #linux #apache #mysql #php
Table of Contents
What is LAMP Stack?
LAMP stack is a popular combination of open-source software widely used for building and deploying web applications. LAMP is an acronym that stands for the following four essential components:
LAMP Stack Components
- Linux:
- Role: The operating system for the stack. Linux provides a stable, secure, and efficient environment for running web applications.
- Features: Open-source, customizable, robust security features, and extensive community support.
- Apache:
- Role: The web server that serves web pages to users.
- Features: Open-source, highly configurable, supports various modules and extensions, and is known for its stability and flexibility.
- MySQL/MariaDB:
- Role: The relational database management system (RDBMS) used to store application data.
- Features: MySQL is known for its speed and reliability, while MariaDB is a MySQL fork with additional features and enhancements. Both support complex queries, transactions, and data management.
- PHP:
- Role: The server-side scripting language used to create dynamic web content.
- Features: Widely used for web development, easy to integrate with HTML, and has a large community and extensive libraries.

Advantages of the LAMP Stack
- Performance: Apache is a robust web server capable of handling a variety of web applications, while MySQL/MariaDB offers high performance for data management.
- Flexibility: The components are highly configurable and can be tailored to specific needs.
- Scalability: The stack can be scaled up or out to handle increasing traffic and data loads.
- Security: Linux and Apache offer strong security features, and MySQL/MariaDB provides various security options for data protection.
- Cost-Effective: All components of the LAMP Stack are open-source and free to use.
- Community Support: Each component has an active community, providing extensive documentation, forums, and resources for support and troubleshooting.
Common Use Cases for the LAMP Stack
- Web Hosting: Ideal for hosting websites and web applications.
- Content Management Systems (CMS): Supports CMS platforms like WordPress, Drupal, and Joomla.
- E-Commerce Platforms: Can be used to build and manage online stores.
- Custom Web Applications: Suitable for developing and deploying custom web applications.
Here, we have selected Red Hat Enterprise Linux (RHEL) 8, Apache HTTP Server 2.4, MySQL 8.0 and PHP 7.2 as the LAMP Stack components.
Recommended Training: Apache Web Server from Vipin Gupta

Environment Specification
A RHEL 8 minimal installed virtual machine is being used in this article. The specifications are:
- CPU – 3.4 Ghz (2 cores)
- Memory – 2 GB
- Storage – 20 GB
- Operating System – Red Hat Enterprise Linux (RHEL) 8
- Hostname – rhel-8-lamp.example.com
- IP Address – 192.168.116.183/24
A Local YUM repository is configured, so we can install required packages without having an active Red Hat subscription.
Install Apache on RHEL 8
Connect with rhel-8-lamp.example.com using ssh as root user.
Since, we have already configured local yum repository, therefore, we can easily install Apache HTTP Server using dnf command.
dnf install -y httpd
Enable and start httpd.service.
systemctl enable httpd.service
systemctl start httpd.service
Allow HTTP service in Linux firewall.
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
Open URL http://rhel-8-lamp.example.com using a web browser.

Apache HTTP Server has been installed and running on our Linux server.
havit HV-F2056 15.6″-17″ Laptop Cooler Cooling Pad – Slim Portable USB Powered (3 Fans), Black/Blue
$27.99 (as of May 18, 2025 16:20 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Install MySQL on RHEL 8
For database back-end installation, we can choose between MySQL and MariaDB.
Since we have already used MariaDB in our previous article Install LEMP Stack on RHEL8 Server, therefore, we are installing MySQL this time.
MySQL 8.0 is available in local AppStream repository, therefore, let’s install it using dnf command.
dnf install -y mysql-server
Start and enable MySQL service.
systemctl enable mysqld.service
systemctl start mysqld.service
Configure and secure MySQL database instance as follows.
mysql_secure_installation
Output:
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Please set the password for root here.
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
Verify MySQL database installation using following command.
mysql -e "SHOW DATABASES;" -p
Output:
Enter password:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
MySQL Database 8.0 has been installed on our Linux server.
Install PHP on RHEL 8
In local AppStream repository, PHP 7.2 is available, therefore, we can install it simply by executing a dnf command.
dnf install -y php php-mysqlnd php-mbstring php-pdo php-gd
During installation, PHP created necessary configuration file in Apache configuration directory. Therefore, we have to restart httpd.service to integrate PHP with Apache HTTP Server.
systemctl restart httpd.service
Create a PHP file to verify PHP installation and its integration with Apache HTTP Service.
echo "<?php phpinfo() ?>" > /var/www/html/info.php
Open URL http://rhel-8-lemp.example.com/info.php in a web browser.

We have successfully install LAMP Stack on RHEL 8.
Ansible For Amazon Web Services AWS By Examples: 10+ Examples To Automate Your AWS Modern Infrastructure
$9.99 (as of May 18, 2025 16:25 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Final Thoughts
By installing the LAMP stack (Linux, Apache, MariaDB, and PHP) on RHEL 8, you’ve set up a proven and versatile platform for hosting dynamic websites and web applications. Throughout this guide, we covered installing each component, configuring essential settings, and verifying the stack’s functionality.
With your LAMP environment ready, you now have a stable and scalable foundation for developing and deploying web-based solutions. Be sure to keep your server updated, secure your applications, and perform regular backups to ensure long-term reliability and performance.
Whether you need cloud optimization, server management, or automation, I provide comprehensive AWS and Linux services. Hire me on Fiverr to elevate your systems.
Leave a Reply
You must be logged in to post a comment.