Install LAMP Stack on CentOS 8 - Step by Step Process ?

LAMP is an open-source web solution stack that is used in web application development. It stands for Linux (L), Apache (A), MySQL (M), and PHP (P). Apache server processes and serves web requests via HTTP. MySQL is a database management system that stores information in a structured format. PHP is a backend scripting language that get information from the database and hand over the processed content to Apache for display.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Apache queries.

In this context, we shall look into how to install LAMP stack on the CentOS 8 system.



What are the Step to take for installing LAMP stack on the CentOS system ?

1. Install Apache

Apache is available in the default CentOS repositories. Therefore, you can simply install it using the Yum package manager. Here is the command to install Apache on CentOS:

$ sudo yum install httpd

Once you execute the above command as sudo, therefore you will be required to enter the sudo password. After that the Terminal might prompt you for confirmation, hit y to confirm, and Apache will be installed on your system.

After the installation is finished, use the command below to start the Apache service:

$ sudo systemctl start httpd.service

Then use the command below to verify the status of the service:

$ sudo systemctl status httpd.service

You will see that the output show that the Apache HTTP server has started and running if everything is in order.

You can also verify the working of the Apache server by visiting the address below:

http://ip-address

If everything is functioning well, you will see the default HTTP TEST web page on your browser.


2. Install MySQL (MariaDB)

Here, we will install the MariaDB database (drop-in replacement of MySQL). It is also available in the default CentOS repositories, so we can simply install it using the command below in the Terminal:

$ sudo yum install mariadb-server mariadb

The Terminal might prompt you for confirmation. Press y to confirm. Now the installation of mentioned packages will be started on your system.

After the installation is finished, use the command below to start the MariaDB service:

$ sudo systemctl start mariadb.service

To verify the status of the service, use the command below:

$ sudo systemctl status mariadb.service

The output will show that MariaDB has been started and running.


3. Install PHP

PHP can also be installed using the CentOS Yum package manager. Here is the command to install the PHP packages:

$ sudo yum install php php-mysqlnd.x86_64

The Terminal might prompt you for confirmation. Press y to confirm. Now the installation of mentioned packages will be started on your system.

Now to make the Apache web server function with PHP, restart the Apache web server:

$ sudo systemctl restart httpd.service

Now to verify that your system is configured properly for PHP, create a file named info.php at /var/www/html/:

$ sudo nano /var/www/html/info.php

Add the below line in the info.php file:

<?php phpinfo(); ?>

Then save and close the file.

Now access the following address in your web browser:

http://ip-address/info.php

If everything is working well, you should see PHP Version default web page on your screen.

After verifying that PHP is working well, you can remove the info.php file using the command below:

$ sudo rm /var/www/html/info.php


[Need help in fixing Apache web server Configuration issues ? We can help you. ]

This article covers how to install the LAMP stack on the CentOS system. If are using another Linux distribution, visit how to install LAMP stack on Debian, Ubuntu, Red Hat, and Rocky Linux. Basically, A LAMP stack is a collection of open-source software that you can use as a platform to create websites and web applications. The term LAMP is an acronym standing for Linux operating system, the Apache HTTP Server, the MySQL database system, and the PHP programming language.


In LAMP:

  • Linux serves as the server's operating system that handles all the commands on the machine.
  • Apache is a web server software that manages HTTP requests to deliver your website's content.
  • MySQL is a relational database management system (RDBMS) whose function is to maintain user's data on a server.
  • PHP is a scripting language for server-side communication.

Related Posts