Install LAMP Stack on CentOS 8
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 LEMP Stack on CentOS 8 [Quickstart]
This quickstart shows the basic steps required to get a LAMP stack installed on a CentOS 8 server.
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 straight forward.
On RHEL based distributions, the Apache package and the service is called httpd. To install the package run the following command:
sudo dnf install httpd
Once the installation is completed, start and enable the Apache service by typing:
sudo systemctl enable --now httpd
Step 2. Installing MySQL
The next step is to install MySQL or MariaDB database server. To do so type:
sudo dnf install @mysql
Once installed, start and enable the service with:
sudo systemctl enable --now mysql
mysql_secure_installation script to secure your server and set the MySQL root password:
You 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 http://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module reset php
sudo dnf module enable php:remi-7.4
Install PHP FPM and several most common PHP modules by typing:
sudo dnf install php php-opcache php-gd php-curl php-mysqlnd
FPM 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-fpm
If SELinux is running on your system, you’ll need to update the SELinux security context:
sudo chcon -tR httpd_sys_rw_content_t /var/www
Restart the Apache service for changes to take effect:
sudo systemctl restart httpd
For more detailed instructions about each step, please consult the following tutorials.
Oct 12, 2019
How to Install Apache on CentOS 8
Oct 17, 2019
How to Install MySQL on CentOS 8
Oct 18, 2019
How to Install PHP on CentOS 8
Oct 28, 2019
Secure Apache with Let's Encrypt on CentOS 8
Mar 3, 2020