This guide describes a step by step tutorial on how to install LAMP stack on CentOS 8.
Installing LAMP Stack on CentOS 8
LAMP is a group of opensource web development softwares; Linux OS, Apache http server, MariaDB/MySQL relational database management systems and PHP web scripting language.
Run system package update.
dnf updateInstall CentOS 8 Linux System
In this case, the first component of the LAMP stack is our CentOS 8 Linux system. To install CentOS 8, see our guide on how to install it on VirtualBox by following the link below;
Install CentOS 8 on VirtualBox
Install Apache HTTP Server on CentOS 8
Apache http server can be installed on CentOS 8 as easily as running the command below;
dnf install httpdRunning Apache
Once the installation is done, you can start and enable Apache to run on system reboot by executing;
systemctl enable --now  httpdTo check the status;
systemctl status httpd● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-10-07 13:59:33 EDT; 42s ago
     Docs: man:httpd.service(8)
 Main PID: 26699 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 11512)
   Memory: 24.8M
   CGroup: /system.slice/httpd.service
           ├─26699 /usr/sbin/httpd -DFOREGROUND
           ├─26700 /usr/sbin/httpd -DFOREGROUND
           ├─26701 /usr/sbin/httpd -DFOREGROUND
           ├─26702 /usr/sbin/httpd -DFOREGROUND
           └─26703 /usr/sbin/httpd -DFOREGROUND
...To verify if it is enabled to run on boot, run the command below. The output should enabled;
systemctl is-enabled httpdAllow Apache Through the FirewallD
To enable external access to Apache web server, you need to allow web traffic on FirewallD. If you are serving just HTTP traffic, just open port 80/tcp otherwise, open port 443/tcp
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reloadTesting Apache
To confirm that Apache is ready to server HTTP content, simply open your browser and enter the server IP address as http://Server.IP. You should land on Apache HTTP server test page.

Install MariaDB Database Server on CentOS 8
Install MariaDB on CentOS 8 with the command;
dnf install mariadb-serverThis installs MariaDB 10.3.
mysql -V
mysql  Ver 15.1 Distrib 10.3.11-MariaDB, for Linux (x86_64) using readline 5.1Want to use MariaDB 10.4 instead, follow the link below to install MariaDB 10.4 on CentOS 8.
Install MariaDB 10.4 on CentOS 8
You can also use MySQL 8 instead;
Once you have installed MariaDB server, start and enable it to run on system boot.
systemctl enable --now  mariadbNext, run the security script to disable remote root login, remove test databases, remove anonymous user accounts.
mysql_secure_installationYou can login to your MariaDB server and create your databases.
Install PHP on CentOS 8
Install PHP and MySQL PHP module on CentOS 8 by running the command;
dnf install php php-mysqlndThe command above installs PHP 7.2. To use PHP 7.3 instead, you need to install remi repos.
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpmdnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpmReset PHP 7.2 module;
dnf module reset php:7.2Enable PHP 7.3 remi repository.
dnf module enable php:remi-7.3Install PHP 7.3 on CentOS 8
dnf install php php-mysqlnd=======================================================================================================================================================
 Package                           Arch                    Version                                                 Repository                     Size
=======================================================================================================================================================
Installing:
 php                               x86_64                  7.3.12-1.el8.remi                                       remi-modular                  3.0 M
 php-mysqlnd                       x86_64                  7.3.12-1.el8.remi                                       remi-modular                  252 k
...Want to use PHP 7.4? See the link below on how to install PHP 7.4 on CentOS 8.
If you need other PHP extensions for your web applications, simply install by running;
dnf install php-EXTENSIONReplacing EXTENSION with your respective PHP module.
Testing PHP on CentOS 8
You can test PHP to confirm that is working as required as well check the version and installed modules using the simple PHP info script.
vim /var/www/html/test.php<?php 
phpinfo(); 
?>Save the file and exit the file.
Restart Apache
systemctl restart httpdNavigate to the browser and enter the address, http://<server-IP>/test.php

There you go, Your LAMP stack is installed on CentOS 8 and is ready for your web development tasks.
Be sure to remove PHP test page.
rm -rf /var/www/html/test.phpRelated Tutorials
Install LAMP Stack on Fedora 30
How To Install LAMP (Linux, Apache, MySQL, PHP) Stack on Fedora 28/29
 
					