In this tutorial, we will show you how to install LAMP Stack on CentOS 8. For those of you who didn’t know, LAMP (a server stack) represents a full-featured stack containing the most popular web server known as Apache, the most popular database server MariaDB and the most popular open-source web programming language known as PHP. All components are free and open-source software, and the combination is suitable for building dynamic web pages.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you through the step by step installation LAMP Stack on a CentOS 8 server.
Install LAMP Stack on CentOS 8
Step 1. First, let’s start by ensuring your system is up-to-date.
Step 2. Installing Apache on CentOS 8.
We will be installing Apache with
dnf, which is the default package manager for CentOS 8:
After installing Apache services on your system, start all required services:
Then, allow Apache HTTP server via the firewall:
You can verify that Apache is really running by opening your favorite web browser and entering the URL http://your-server’s-address.
Step 3. Installing MariaDB on CentOS 8.
MariaDB is a drop-in replacement for MySQL. It is a robust, scalable, and reliable SQL server that comes a rich set of enhancements. We will also be using yum to install MariaDB:
By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:
To log into MariaDB, use the following command (note that it’s the same command you would use to log into a MariaDB database):
Then, restart the MariaDB database server and enable it to start on system start-up using:
Finally, run the commands below to install PHP along with other good-to-have modules:
Restart Apache using
systemctl for the changes to take effect:
Now, it is time to test it. Create a new file called test.php on /var/www/html and add the following:
Congratulations! You have successfully installed LAMP. Thanks for using this tutorial for installing LAMP (Apache, MariaDB, and PHP) on CentOS 8 system. For additional help or useful information, we recommend you to check the official Apache, MariaDB, and PHP website.