Install LAMP Stack on CentOS 8
A 5-part series covering lamp and centos

The term LAMP is an acronym of the names of the following four open-source components:
- L - Linux operating system.
- A - Apache, the world’s most popular HTTP web server.
- M - MySQL or MariaDB relational database management system.
- P - PHP programming language.
The LAMP stack is generally used for developing and deploying dynamic PHP applications such as WordPress, Laravel, and Drupal.
In this series, we’ll cover how to install Apache, generate a free Let’s Encrypt SSL certificate, install and secure MySQL, and install PHP 7.
If you are in a hurry and don’t want to read more detailed documentation, you can install LAMP Stack on your CentOS 8 server by following our Quickstart section.
Install LAMP Stack on CentOS 8 [Quickstart]
This quickstart shows the basic steps required to get a LAMP stack installed on a CentOS 8 server.
Prerequisites
The user you are logged in as must have sudo privileges to be able to install packages.
Step 1. Installing Apache
Apache is available in the default CentOS 8 repositories, and the installation is pretty straightforward.
On RHEL-based distributions, the Apache package and the service are called httpd. To install the package, run the following command:
sudo dnf install httpdOnce the installation is completed, start and enable the Apache service by typing:
sudo systemctl enable --now httpdStep 2. Installing MySQL
The next step is to install MySQL or MariaDB database server. To do so, type:
sudo dnf install @mysqlOnce installed, start and enable the service with:
sudo systemctl enable --now mysqlRun the mysql_secure_installation script to secure your server and set the MySQL root password:
mysql_secure_installationYou will be asked to configure the VALIDATE PASSWORD PLUGIN
, which is used to test the strength of the MySQL users’ passwords and improve the security. There are three levels of password validation policy, low, medium, and strong. Press ENTER if you don’t want to set up the validate password plugin.
Step 3. Installing PHP
CentOS 8 is distributed with PHP 7.2. This version supports most of the modern PHP applications, but will no longer be actively maintained as of November 2019. The newer PHP versions are available from the Remi repository. We’ll install PHP 7.4.
Run the following command to install the Remi repository and enable PHP 7.4:
sudo dnf install dnf-utils https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module reset php
sudo dnf module enable php:remi-7.4Install PHP FPM and several of the most common PHP modules by typing:
sudo dnf install php php-opcache php-gd php-curl php-mysqlndFPM is installed as a dependency and used as a FastCGI server. Start the FPM service and enable it to automatically start on boot:
sudo systemctl enable --now php-fpmIf SELinux is running on your system, you’ll need to update the SELinux security context:
sudo chcon -Rt httpd_sys_rw_content_t /var/wwwRestart the Apache service for changes to take effect:
sudo systemctl restart httpdMore Information
For more detailed instructions about each step, please consult the following tutorials.