Install LAMP Stack (Linux, Apache, MySQL, PHP) with PHPMyAdmin on RHEL 8 and CentOS 8

 LAMP Stack (Linux, Apache, MySQL, PHP) with PHPMyAdmin on RHEL 8 and CentOS 8

Introduction:

A “LAMP” stack is a group of open source software that is typically installed together in order to enable a server to host dynamic websites and web apps written in PHP. This term is an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP.

In this guide, you’ll set up a LAMP stack on an RHEL 8 and CentOS 8 server.

Type the following command to find OS name and version:

# cat /etc/*rel*


check my youtube video "Install LAMP Stack with PHPMyAdmin on RHEL 8 and CentOS 8 Server" for your reference.
                                                                                                                                                                     
Apache / HTTPD:

You will need to have root user access. So, open the terminal and login to the server as the root user.

# sudo su -

Now perform the update using dnf.

# dnf update --nobest -y

Apache is one of the most widely used web server and to install it we need to run the following command.

# dnf install httpd httpd-tools net-tools vim -y

Once the installation is complete, Start and enable Apache to auto-start at system boot time using the command below.

# systemctl start httpd
# systemctl enable httpd

To confirm is Apache web service is running, run the command.
# systemctl status httpd

After, update the firewall rules to allow requests to web server.

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

Checking 80 Port is enabled and running:
# netstat -ntlp | grep -i 80
Once we have Apache start, we need to create Apache conf file only for Domain HOST. 
# cd /etc/httpd/conf.d

Create and paste below mentioned details in conf file.

# vim meetdarji.conf

<VirtualHost *:80>

        ServerName meetdarji.com
        DocumentRoot /var/www/html/meetdarji.com

        ErrorLog /var/log/httpd/meetdarji.error.log
        CustomLog /var/log/httpd/meetdarji.log combined

<Directory /var/www/html/meetdarji.com>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted

</Directory>
</VirtualHost>

Save and exit using ':wq!', Now create HTML file for website front page.

# cd /var/www/html/
# mkdir meetdarji.com
# cd meetdarji.com
# vim index.html

<html>
<head>
<title>
Meet Darji
</title>
<style>
body {
text-align: center;
}
h1 {
color: green;
}
</style>
</head>
<body>
<h1>Meet Darji</h1>
<h2>
Please Like Share and Subscribe
</h2>
<p>
<b>https://www.youtube.com/c/meetdarji</b>
</p>
</body>
</html>

Before restarting the Apache service, Check your configuration is correct or not using the "httpd -t" command and restart the Apache service.

# httpd -t
# systemctl restart httpd


Once all is done, test by accessing your server’s IP or Domain name in your browser:

Apache Configuration is Working...😀

                                                                                                                                                                     
Mysql / MariaDB:

MariaDB is a fork of MySQL database . It was developed by a former team of MySQL who had concerns that Oracle may turn MySQL to a closed-source project. It ships with innovative and better features than MySQL that make it a better option than MySQL.

To install MariaDB, run the command.
# dnf install mariadb-server mariadb -y

Once installed, Start and enable MariaDB service:
# systemctl start mariadb
# systemctl enable mariadb
# systemctl status mariadb

Once start service, Secure your newly installed MariaDB service by creating a ROOT password using the following steps:

# mysql_secure_installation

Now login in MySQL with Root user:
# mysql -u root -p
# exit

It's Working...😀

                                                                                                                                                                     
PHPmyadmin:

phpMyAdmin is a web-based tool written in PHP to manage the MySQL database. Apart from viewing the tables (and other db objects), you can perform lot of DBA functions through the web based interface. You can also execute any SQL query from the UI.

Install PHP:

Run the following command to install PHP:
# yum install php php-cli php-json php-mbstring php-pdo php-pecl-zip php-xml php-mysqlnd php-json unzip wget -y

Check the PHP installation and version:
# php -v

Install PHPMyAdmin:
The phpMyAdmin tool is not included in the default CentOS 8 repositories. However, the file can be download manually.

Official download link of PHPMyAdmin: https://www.phpmyadmin.net/files

Following commands to download the phpMyAdmin file:
# cd /var/www/html
# wget https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-languages.zip

Extract the .zip file archive and remove zip file:
# unzip phpMyAdmin-5.1.0-all-languages.zip
# rm -rf phpMyAdmin-5.1.0-all-languages.zip

Rename phpMyAdmin-5.1.0-all-languages directory to phpmyadmin: 
# mv phpMyAdmin-5.1.0-all-languages phpmyadmin

Set permissions on a phpmyadmin directory:
# chown -R apache:apache phpmyadmin
# ls -l

Change directory:
# cd phpmyadmin/

Rename the sample php configuration file:
# mv config.sample.inc.php config.inc.php

Open the "php configuration" file for editing:
# vim config.inc.php

Find the following line:
$cfg['blowfish_secret'] = '';                __ (16 Line)

Edit the line and enter the new php root password between the single-quotes, as follows:
$cfg['blowfish_secret'] = 'meetdarji';

Save and close the file. Then, import the tables for phpMyAdmin with the following command:
# mysql -u root -p < sql/create_tables.sql

Configure Apache for phpMyAdmin
Create an Apache configuration file:
# cd /etc/httpd/conf.d/
# vim phpmyadmin.conf
This creates a new, blank configuration file. Enter the following code:

Alias /phpmyadmin /var/www/html/phpmyadmin

<Directory /var/www/html/phpmyadmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
      Require all granted
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

<Directory /var/www/html/phpmyadmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require all granted
     </RequireAny>

   </IfModule>

   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>

</Directory>

Save and close the file.

Finally, restart the Apache service to apply the changes made in the configuration file:
# systemctl restart httpd


You can now access the web interface by visiting your server’s domain name or public IP address followed by /phpmyadmin:


Lastly, I hope it's helpful. So, let me know your suggestions and feedback using the comment section.


check my youtube video "Install LAMP Stack with PHPMyAdmin on RHEL 8 and CentOS 8 Server" for your reference.

Tags:
How to Install the LAMP Stack on centos 8
How to Install the LAMP Stack on redhat 8
How to Install the LAMP Stack on rhel 8
How to Install the LAMP Stack on Linux
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on centos
LAMP Applications
Install LAMP Stack (Linux, Apache, MySQL, PHP) in centos
How to Install an Apache LAMP Server on centos 8
How to install and run Apache web server in centos Linux
How to Install Apache 2 on centos 8
How to Install Apache on Linux - centos
How to Install MySQL on centos
How to Install MySQL on centos 8
phpmyadmin install centos
Install phpMyAdmin On centos 8
How to install phpMyAdmin on centos
How to Install LAMP server and PHPMyAdmin on centos
How To Install Phpmyadmin With Apache Lamp On centos
Install LAMP Stack (Linux, Apache, MySQL, PHP) with PHPMyAdmin on RHEL 8 and CentOS 8

Comments

Contact Form

Name

Email *

Message *

Popular posts from this blog

Red Hat Certified Systems Administrator – RHCSA (EX200) Ex@m practice 2022

Step-by-Step Install and Configure OpenLDAP on RHEL7/CentOS 7 Linux

Creating RAID-0 (Stripe) in Linux