Quick Installation of LAMP Apache MySQL/MariaDB PHP on CentOS 8

How to use dnf to quickly install LAMP, Apache+MySQL/MariaDB+PHP environment on CentOS 8?
This installation method has been tested on Google Cloud and should work on AWS, DigitalOcean, or any cloud hosting service or on any VPS or dedicated server.


What is?
LAMP is an acronym for a group of free software commonly used together to run dynamic websites or servers:
Linux, the operating system
, web server
or, database management system (or database server)
PHP, Perl or Python, scripting language
Although these open source programs themselves are not specifically designed to work with other programs, the combination has become popular due to their cheapness and ubiquity (most Linux distributions bundle these software). When used together, they behave like a dynamic "solution package". Other solution packages include Apple's WebObjects (originally an application server), Java/J2EE, and Microsoft's .NET framework.
The scripting component of the "LAMP stack" includes the CGI web interface, which became popular in the early 1990s. This technology allows users of web browsers to execute a program on a server and receive dynamic content as well as static content. Programmers use scripting languages to create these programs because they can easily and efficiently manipulate text streams, even when the text streams do not originate from the program itself. It is for this reason that system designers often call these scripting languages glue languages.
How to How to use dnf to quickly install LAMP, Apache+MySQL/MariaDB+PHP environment on 8?
This installation method has been tested on Google Cloud and should work on AWS, DigitalOcean, or any cloud hosting service or on any VPS or dedicated server.
Preparation
If you are using Google Cloud, you can follow these settings, otherwise you can skip.
Your Compute Engine instance is running.
For information about setting up Compute Engine, see:Google Cloud Configuration Guide, detailing how to create a VM instance
Visit the Chinese version of Google cloud official website
Update Packages
You can start the installation by updating the packages to the latest version using the following command.

dnf update

Install Apache WEB Server on CentOS 8
It is very simple to install Apache in CentOS, which is better known as httpd. Run the following command to install it.

dnf install httpd

After the installation is complete, enable and start the Apache service.

systemctl enable httpd systemctl start httpd

If your server is behind a firewall, open HTTP and HTTPS ports. Use the following commands to enable them.

firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --permanent --zone=public --add-service=https firewall-cmd --reload

You can view the installation status of Apache. Each process in Apache is operated by the systemctl command. Use the following command to view the installation status of Apache.

systemctl status httpd


A green light indicates that the installation has been successful!
Install MySQL/MariaDB Database on CentOS 8
MariaDB is a better alternative to MySQL, so we can use MariaDB instead of MySQL. Start MariaDB, set it to start at boot, and then check the status of MariaDB.

dnf install mariadb-server mariadb -y systemctl enable mariadb systemctl start mariadb systemctl status mariadb

Create a MariaDB server password using the mysql_secure_installation command.

mysql_secure_installation


Follow the prompts and create a new password for the root user, then complete the MariaDB setup process.
Install PHP on CentOS 8
Finally, install PHP. By default, the PHP version installed in CentOS 8 is 7.4. So, you can install PHP using the following command.

dnf install -y php php-mysqlnd systemctl start php-fpm systemctl enable php-fpm

Restart the apache service.

sudo systemctl restart httpd

Verify LAMP setup
Create a PHP probe file info.php to output PHP information.
Install nano editor, a handy editor for creating and editing new files.

dnf install nano -y nano /var/www/html/info.php

The contents of the info.php file are as follows

 

Now open your browser, enter your server’s external IP address and point to info.php in the URL.

http://IP_Address/info.php


You will see the configuration information for PHP, which indicates that you have installed and configured Apache, MariaDB, and PHP on your CentOS 8 server.
Now you have learned how to install the LAMP environment on CentOS 8. Now the installation is just an initial LAMP environment, and there are still many places to configure. Apache, MySQL and PHP configuration issues can be found in the search on this site.

1/5 - (1 vote)

Leave a Reply

Your email address will not be published. Required fields are marked *