What is LAMP stack? How to install LAMP server on Centos7, Red Hat and Fedora with 12 easy steps

In this article, We will tell you what is LAMP stack, this article applicable for Centos7, Red Hat and Fedora. You’re in the right place to know all about LAMP. By going through this article you will learnt process from installation to the creation of your first working PHP file step by step.

Introduction of what is lamp stack

LAMP is an open source Web development platform that uses Linux as the operating system,
Apache as the Web server, MySQL as the relational database management system and PHP as
the object-oriented scripting language.


This article show you how, what is lamp stack and how to install, configure it on CentOS7, Red Hat and Fedora. So, we are assuming you have already installed your OS (CentOS7, Red Hat and Fedora) Before installing new packages on the system, it may be production or test server, you should always update your server by using command #yum update -y  to be sure you have the latest updates & versions installed.


Step1. Install web server

To install web server we have to install package httpd. use below command,

#yum install httpd


Step2. Install database server

To install database server we have to install package mariadb and mariadb-server. Use below command,

 #yum install mariadb mariadb-server -y

Now, start and enable services and check the status using below commands,

 #systemctl start mariadb
#systemctl enable mariadb
#systemctl status mariadb

Step3. Configure database

Use below command to configure database,


While creating a database you have to follow and answers to certain things,                                                                            Enter current mysql root password (Not system Root password) if you have, if not just hit enter, it will ask you to set new root password for database. and follow the below settings,

Remove anonymous users    Y
Disallow root login remotely Y
Remove test database and access to it Y
Reload previlage tables now Y

Step4. Restart database service

Now, restart database service, use below command,

Command: #systemctl restart mariadb

Step5. Install PHP

Use below command to install PHP packages,

 #yum install php -y

Step6. Integration of PHP and database

Use below commands to integrate PHP and database, you can also check installed PHP versions,

 #yum install php-mysql
 #php --version

Step7. Start web server service and check status

Use below commands to perform this activities,

#systemctl start httpd
#systemctl enable httpd
#systemctl status httpd

Step8. Installed firewall for secure your server

Use below command to install firewall package,

#yum install firewalld -y

Step9. Apply Firewall rules to secure server

Use below commands, to allow only those services which required to allow

#firewall-cmd --permanent --add-service=mysql
#firewall-cmd --reload

Step10. Create index.php file for testing

Use below step and commands to create index.php file for testing.

#cd /var/www/html
 #vim index.php

Now, write below php code and save file using :wq option.

phpinfo() ;

Step11. Testing

Check PHP configuration, by typing localhost or local IP Address of your machine in your the web browser. Your installation and configuration completed successfully If you get PHP info page.

Step12. Verify database connection

To check your database connection with PHP you just have to search mysql on the same PHP info page.
You could see the details about “mysql” and its enabled”


This way you knows now What is lamp stack? How to install LAMP on Centos7, Red Hat and Fedora.                  Hope this article helpful for you.

You could check out our related article here  How to secure your linux server




Recent articles

What is CI-CD, Understand with 5 easy steps

How to install Jenkins with 5 easy steps

What is devops ? 15 smart and powerful tools

Download and install redhat linux 8 with 5 easy steps


Thanks for visiting to https://devopsarticle.com

Suresh Dike

Suresh Dike I am Suresh, working on Cloud, DevOps, Linux, Firewalls,Docker and Kubernetes. Believes in sharing the knowledge.

1 thought on “What is LAMP stack? How to install LAMP server on Centos7, Red Hat and Fedora with 12 easy steps”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.