LAMP Installation on CentOS and RHEL8/7

LAMP  (Linux, Apache, MariaDB/MySQL and PHP) Stack is a bundled of software together i.e Linux, Apache, MariaDB/MySQL and PHP. This is the most common software stack in today’s internet to host dynamic websites and web applications. 

1. Linux – Operating System (CentOS, RedHat, Ubuntu, SUSE, Debian etc.).
2. Apache – Web Server (Web pages or content will be served).
3. MariaDB/MySQL – is a Relational Database Server.
4. PHP – Server-side scripting language to generate dynamic web pages.

Prerequisites:
  1. Running instance of Operating System (CentOS & RedHat)
  2. root or sudo access
  3. Internet access to download applications
1. RedHat / CentOS Linux Installation:
Our System informations (click on picture to enlarge it).
2. Install Apache Web Server with basic configurations

After installing of RHEL/CentOS Linux and assigning static IP address on your system, follow below steps to install Apache Web Server.
# dnf update
or 

# yum update
Install Apache with below command (click on picture to enlarge it).
# dnf install httpd

After successful installation of Apache Web Server, use following command to manage Apache service (click on picture to enlarge it).

# systemctl start|stop|restart|status|reload httpd
or
# systemctl  httpd start|stop|restart|status|reload


Open Apache default port 80 on system firewall with following command:
# firewall-cmd –state
# firewall-cmd –list-all
# firewall-cmd –zone=public –permanent –add-service=http
# firewall-cmd –reload

In our case system firewall service is running so we have added the rule to open HTTP service permanently on our system as shown below screenshot (click on picture to enlarge it).

Testing Apache Web Server 
Open Web Browser and enter IP address which we have noted during CentOS / RHEL installation steps, we should see the Apache HTTP Server Test Page as shown below (click on picture to enlarge it).

3. Install MariaDB / MySQL Database Server.

Please follow below link to install MariaDB and MySQL CE Installation.
4. Install PHP 
Install PHP with some common modules with below command. Apache Web Server uses default PHP-FPM or mod_php to run PHP code, after installation we need to restart php-fpm along with httpd service (click on picture to enlarge it).
# yum install php php-fpm php-mysqlnd php-opcache php-gd php-xml php-mbstring
Start/Restart php-fpmhttpd service (click on picture to enlarge it).
# systemctl start php-fpm
# systemctl enable php-fpm 
# systemctl status php-fpm
# systemctl restart httpd
Testing PHP
To get PHP information from browser, create a info.php file Apache document root using below command. And browse as http://IP_Address/info.php

 

# echo “<?php phpinfo(); ?>” > /var/www/html/info.php

 

# systemctl restart httpd

 

Above screenshot indicates that PHP is working and should be able to see the PHP info page in the web browser.
Conclusion: In this tutorial, we have installed Basic LAMP (Linux, Apache, MariaDB and PHP) Stack installation. Big thanks for reading all the way to the end. Please share it with Your Friends & Help Someone… and also Like Our Facebook Page. Let me hear your thoughts in the comments below!

Leave a Comment