In this post, you’ll install the LAMP stack on CentOS 8 server. Although MySQL is available from the default repositories in CentOS 8, this guide will walk through the process of setting up a LAMP stack with MariaDB as the database management system.
Point1: To follow this guide, you’ll need access to a CentOS 8 server as a root user.
Install LAMP stack on CentOS 8
Step A: Install Apache on Centos 8
Install the httpd package with:
dnf install httpd
After the installation is finished, run the following command to enable and start the server:
systemctl start httpd systemctl enable httpd
If firewalld is active, you’ll need to run the following command to allow external access on port 80:
firewall-cmd --permanent --add-service=http firewall-cmd --reload
you can test if the server is up and running by accessing your server’s public IP address or domain name from your web browser. You’ll see a page like this:
Step B: Install MariaDB on Centos 8
We’ll now install MariaDB, a community-developed fork of the original MySQL server by Oracle. To install this, run:
dnf install mariadb-server
After installation, enable and start the MariaDB server with this command:
systemctl start mariadb systemctl enable mariadb
For more security of your database you have to run following command and follow the instruction:
The first prompt will ask you to enter the current database root password and because you don’t have any password yet, just press Enter key to continue steps.
Now you have to type a new password for root and confirmation. after that you can skip all steps with press Y and Enter.
Step C: Install PHP on Centos 8
To install the PHP and PHP-mysqlnd following the command:
dnf install php php-mysqlnd
Now, you have to restart Apache after installation complete.
systemctl restart httpd
Step D: Test PHP with Apache on CentOS 8
We’ll now create a test PHP page to make sure the Web server works as expected.
Copy and paste below code on the file open
Now, press Esc and type :wq for saving the file.
To test your web server can correctly display content generated by a PHP, go to your browser and access your server hostname or IP address with /info.php. Like :
IF all configuration is OK, you see a page like this:
In install LAMP stack on CentOS 8 tutorial you learn how to install Apache, MariaDB and PHP on your server.