input license here

Instructions for installing LAMP Stack on CentOS 8


LAMP Stack stands for Linux, Apache, MariaDB and PHP. It is most widely used for hosting websites, blogs, etc.

Here's a small guide to installing and configuring LAMP Stack with the latest release of CentOS 8.


Install Linux


If your device does not have CentOS 8 installed, you can follow the instructions below to install it.

Now your device is ready with CentOS 8 and you can start installing Apache, MariaDB, PHP.

Note: The commands in the instructions below will be executed under the root user, if you are not the root user, add "sudo" to the beginning of each command.

Install Apache Web Server


  • The package name of Apache is httpd. Use the package manager yum to install
# yum install -y httpd

  • Start the Apache service using the command systemctl
# systemctl start httpd

  • Configure to allow Apache to be started with the system
# systemctl enable httpd

  • Check the status of the Apache service using the command below
# systemctl status httpd

  • Check the default Apache port
# ss -plnt | grep httpd

OUPUT

LISTEN   0         128                       *:80                     *:*        users:(("httpd",pid=9339,fd=4),("httpd",pid=9338,fd=4),("httpd",pid=9337,fd=4),("httpd",pid=9335,fd=4))

Accordingly, the default port Apache uses is port 80.

By default, the firewall blocks incoming HTTP connections from outside machines. Therefore, to test or use the Apache web server, we need to configure the firewall to allow HTTP requests from external machines.

# firewall-cmd --permanent --add-port=80/tcp
# firewall-cmd --reload

  • Check out the operation of Apache
Open your browser, enter in the search bar the server's IP address. You will get the result as an Apache test page. This test page confirms that Apache is working well.



The default Apache root document is / var / www / html, the main configuration file is /etc/httpd/conf/httpd.conf. Additional configurations for the Apache web server are stored in the /etc/httpd/conf.d directory

Install MariaDB


This tutorial will guide you to install MariaDB from the operating system repository. You can also install MariaDB from the archive of the MariaDB community.

READ: Install MariaDB 10.4.8 on CentOS 8

  • Use the following command to install
# yum install -y mariadb mariadb-server

  • Start the MariaDB Server service with the systemctl command
# systemctl start mariadb

  • Configuration allows the MariaDB Server service to start with the system
# systemctl enable mariadb

  • Check the status of MariaDB Server services
# systemctl status mariadb

OUTPUT


Install LAMP Stack on CentOS 8 - MariaDB Server Status

Secure MariaDB


Usage statement

# mysql_secure_installation

This command allows you to improve the security of installing MariaDB in the following ways:

  • Set a password for the root account.

  • Delete the root account accessible from outside localhost.

  • Delete anonymous user accounts.

  • Deleting the test database (by default can be accessed by all users, even anonymous users) and privileges that allow people to access the database whose name starts with test_.
OUTPUT


Install LAMP Stack on CentOS 8 - Secure MariaDB Installation

Install PHP


By default Apahe Web Server only supports HTML language. To have PHP support we will have to install the PHP package.

CentOS 8 uses PHP v7.2 by default. In case you want to use PHP v7.3 you can follow the following instructions

READ: Instructions to install PHP v7.3 on CentOS 8

  • PHP installation command
# yum install -y php php-mysqlnd

  • Restart the Apache Web Server service to confirm the use of PHP
# systemctl restart httpd

LAMP Stack test


To test PHP, create an info.php file in the default Apache directory

# echo "" > /var/www/html/info.php

Then use your browser to enter the following address search bar, replace 192.168.136.100 with your Server IP address.

http://192.168.136.100/info.php

Your page will then look like this. You can see information about the installed PHP version, extension details, etc.



Scroll down the browser to check support for MariaDB. You will get the screen as below.



Good luck!

Related Posts
Diệp Quân
Nguyen Manh Cuong is the author and founder of the vmwareplayerfree blog. With over 14 years of experience in Online Marketing, he now runs a number of successful websites, and occasionally shares his experience & knowledge on this blog.
SHARE

Related Posts

Subscribe to get free updates

Post a Comment

Sticky