How to Install and Configure the Lamp Server on Linux Mint 20

To Install & Configure the LAMP server on Linux Mint 20

Introduction:

The expansion of the LAMP is Linux, Apache, MySQL, PHP. In this setup, Apache, MySQL, and PHP must be installed to the Linux OS. This tutorial covers the installation process of squid proxy on Linux Mint 20.

Run the following command to install apache

root@linuxhelp:~# apt-get install apache2
Reading package lists... Done
Building dependency tree       
Reading state information... Done

.
.
.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
Processing triggers for ufw (0.36-6) ...
Processing triggers for systemd (245.4-4ubuntu3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...

After the apache2 service is installed, start the service by triggering the following command:

root@linuxhelp:~# systemctl start apache2

Now check its status by using the following command:

root@linuxhelp:~# systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-11-02 14:35:18 IST; 8min ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 2831 (apache2)
      Tasks: 55 (limit: 2244)
     Memory: 5.9M
     CGroup: /system.slice/apache2.service
             ├─2831 /usr/sbin/apache2 -k start
             ├─2834 /usr/sbin/apache2 -k start
             └─2835 /usr/sbin/apache2 -k start

Nov 02 14:35:18 linuxhelp systemd[1]: Starting The Apache HTTP Server...
Nov 02 14:35:18 linuxhelp apachectl[2830]: AH00558: apache2: Could not reliably determine the server's fully qualified do>
Nov 02 14:35:18 linuxhelp systemd[1]: Started The Apache HTTP Server.

After the status is checked, install MariaDB service as follows.

root@linuxhelp:~# apt-get install mariadb-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
.
.
.
Setting up mariadb-server (1:10.3.22-1ubuntu1) ...
Processing triggers for systemd (245.4-4ubuntu3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for doc-base (0.10.9) ...
Processing 1 added doc-base file...

After installation process the service is started by triggering the following command:

root@linuxhelp:~# systemctl start mariadb

And then, check its status by using the following command:

root@linuxhelp:~# systemctl status mariadb
● mariadb.service - MariaDB 10.3.22 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-11-02 14:49:39 IST; 1min 14s ago
       Docs: man:mysqld(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 4962 (mysqld)
     Status: "Taking your SQL requests now..."
      Tasks: 31 (limit: 2244)
     Memory: 70.3M
     CGroup: /system.slice/mariadb.service
             └─4962 /usr/sbin/mysqld

Nov 02 14:49:40 linuxhelp /etc/mysql/debian-start[5000]: information_schema
Nov 02 14:49:40 linuxhelp /etc/mysql/debian-start[5000]: mysql
Nov 02 14:49:40 linuxhelp /etc/mysql/debian-start[5000]: performance_schema
Nov 02 14:49:40 linuxhelp /etc/mysql/debian-start[5000]: Phase 6/7: Checking and upgrading tables
Nov 02 14:49:40 linuxhelp /etc/mysql/debian-start[5000]: Processing databases
Nov 02 14:49:40 linuxhelp /etc/mysql/debian-start[5000]: information_schema
Nov 02 14:49:40 linuxhelp /etc/mysql/debian-start[5000]: performance_schema
Nov 02 14:49:40 linuxhelp /etc/mysql/debian-start[5000]: Phase 7/7: Running 'FLUSH PRIVILEGES'
Nov 02 14:49:40 linuxhelp /etc/mysql/debian-start[5000]: OK
Nov 02 14:49:40 linuxhelp /etc/mysql/debian-start[5060]: Triggering myisam-recover for all MyISAM tables and aria-recover>

After the status is checked, create the credentials of the service by using the following command:

root@linuxhelp:~# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): 
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] 
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
 ... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

After creating the credentials, install PHP by using the following command:

root@linuxhelp:~# apt-get install php libapache2-mod-php php-mysql
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 libapache2-mod-php all 2:7.4+75 [2,836 B]
Selecting previously unselected package php7.4-common.
.
.
.
apache2_invoke: Enable module php7.4
Setting up php7.4 (7.4.3-4ubuntu2.4) ...
Setting up libapache2-mod-php (2:7.4+75) ...
Setting up php (2:7.4+75) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for php7.4-cli (7.4.3-4ubuntu2.4) ...
Processing triggers for libapache2-mod-php7.4 (7.4.3-4ubuntu2.4) ...

Now configure some rules on info.php file by using the following command:

root@linuxhelp:~# vi /var/www/html/info.php

After configuration, restart the Apache service by using the following command:

root@linuxhelp:~# systemctl restart apache2

Open new tab for Checking php service on Browser Navigate the browser and open new tab for Checking Apache2 service

With this, the method of installation LAMP server on LinuxMint 20 comes to an end.

FAQ
Q
What is the default port number of HTTP and HTTPS?
A
The default port numbers of HTTP is 80 and HTTPS is 443
Q
What is the command to create a credential on MySQL or MariaDB?
A
mysql_secure_installation
Q
How to configure a PHP?
A
vi /var/www/html/phpinfo.php

phpinfo();
?>
Q
How to check the status of MySQL and apache server?
A
Apache: systemctl status apache2
Mysql: systemctl status mysql
Q
How to install an entire LAMP package?
A
apt install LAMP server^ (Here ^ the caret symbol is denoted entire
package of LAMP server)