Install LAMP Stack on CentOS 8
The term LAMP is an acronym of the names of its 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
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.
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 MariaDB
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 to your system:
sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
Now that the Remi repository is enabled, install PHP FPM and several most common PHP modules by typing:
sudo dnf install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql
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.
Apr 27, 2018
How to Install Apache on CentOS 7
May 23, 2018
Install MySQL on CentOS 7
Aug 17, 2018
How to Set Up Apache Virtual Hosts on CentOS 7
Sep 8, 2018