How to install Linux,Apache,Mysql,PHP(LAMP) in Ubuntu 20.10?
Blog Standard

How to install Linux,Apache,Mysql,PHP(LAMP) in Ubuntu 20.10?

LAMP is an open source software package used to built dynamic websites.LAMP is an abbreviation that uses the first letter of each of the packages included in it: Linux, Apache, MariaDB, and PHP.Here we are going to install Apache, MariaDB and PHP separately.

How to install Apache2 in Ubuntu 20.10?

Apache2 is an open-source highly extensible web/HTTP server software used by numerous websites on the internet.

To install Apache2, follow default package managerfor that type command:

$ sudo apt install apache2

[email protected]:~$ sudo apt install apache2
[sudo] password for shinimol:
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
0 upgraded, 9 newly installed, 0 to remove and 4 not upgraded.
Need to get 1,843 kB of archives.
After this operation, 8,012 kB of additional disk space will be used.
Do you want to continue? [Y/n] y

 

Here type 'y' for confirmation.

Now, Apache2 service is up and enables on boot can be confirmed using systemctl commands.
$ sudo systemctl status apache2
and
$ systemctl is-enabled apache2

[email protected]:~$ sudo 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-30 12:13:31 IST; 1min 4s ago
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 2769 (apache2)
Tasks: 55 (limit: 4546)
Memory: 6.3M
CGroup: /system.slice/apache2.service
├─2769 /usr/sbin/apache2 -k start
├─2770 /usr/sbin/apache2 -k start
└─2771 /usr/sbin/apache2 -k start
Nov 30 12:13:31 shinimol-Lenovo-G50-80 systemd[1]: Starting The Apache HTTP Server…
Nov 30 12:13:31 shinimol-Lenovo-G50-80 apachectl[2768]: AH00558: apache2: Could not reliably determine the server's fully qualified domain na>
Nov 30 12:13:31 shinimol-Lenovo-G50-80 systemd[1]: Started The Apache HTTP Server.
[email protected]:~$ sudo systemctl is-enabled apache2

enabled

How to install Mariadb in Ubuntu 20.10?

Now we are going to install Mariadb.MariaDB is a fork of the popular MySQL database. To install use command:
$ sudo apt install mariadb-server mariadb-client

[email protected]:~$ sudo apt install mariadb-server mariadb-client
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mariadb-perl libdbi-perl libfcgi-perl
libhtml-template-perl libreadline5 libsigsegv2 libsnappy1v5 libterm-readkey-perl mariadb-client-10.3 mariadb-client-core-10.3
mariadb-common mariadb-server-10.3 mariadb-server-core-10.3 socat
Suggested packages:
gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test tinyca
The following NEW packages will be installed:
galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mariadb-perl libdbi-perl libfcgi-perl
libhtml-template-perl libreadline5 libsigsegv2 libsnappy1v5 libterm-readkey-perl mariadb-client mariadb-client-10.3
mariadb-client-core-10.3 mariadb-common mariadb-server mariadb-server-10.3 mariadb-server-core-10.3 socat
0 upgraded, 22 newly installed, 0 to remove and 4 not upgraded.
Need to get 19.9 MB of archives.
After this operation, 166 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

 

Type 'y' for confirmation

When Mariadb is installed successfully,to confirm that the MariaDB database service is running and is enabled to automatically start when your system is restarted, use following commands.
$ sudo systemctl status mariadb

[email protected]:~$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.3.25 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-11-30 12:18:26 IST; 32s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 4648 (mysqld)
Status: "Taking your SQL requests now…"
Tasks: 31 (limit: 4546)
Memory: 67.5M
CGroup: /system.slice/mariadb.service
└─4648 /usr/sbin/mysqld
Nov 30 12:18:30 shinimol-Lenovo-G50-80 /etc/mysql/debian-start[4687]: information_schema
Nov 30 12:18:30 shinimol-Lenovo-G50-80 /etc/mysql/debian-start[4687]: mysql
Nov 30 12:18:30 shinimol-Lenovo-G50-80 /etc/mysql/debian-start[4687]: performance_schema
Nov 30 12:18:30 shinimol-Lenovo-G50-80 /etc/mysql/debian-start[4687]: Phase 6/7: Checking and upgrading tables
Nov 30 12:18:30 shinimol-Lenovo-G50-80 /etc/mysql/debian-start[4687]: Processing databases
Nov 30 12:18:30 shinimol-Lenovo-G50-80 /etc/mysql/debian-start[4687]: information_schema
Nov 30 12:18:30 shinimol-Lenovo-G50-80 /etc/mysql/debian-start[4687]: performance_schema
Nov 30 12:18:30 shinimol-Lenovo-G50-80 /etc/mysql/debian-start[4687]: Phase 7/7: Running 'FLUSH PRIVILEGES'
Nov 30 12:18:30 shinimol-Lenovo-G50-80 /etc/mysql/debian-start[4687]: OK
Nov 30 12:18:30 shinimol-Lenovo-G50-80 debian-start[5271]: WARNING: tempfile is deprecated; consider using mktemp instead.

To enable some basic security measures for the MariaDB database installation, by running the mysql_secure_installation script which ships with the MariaDB package. For that, use command:

$ sudo mysql_secure_installation

[email protected]:~$ sudo mysql_secure_installation

 

Since, MariaDB is installed on first time, left blank on password.

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.

 

Now will ask a series of yes or no questions during installation steps.They are
Enter current password for root (enter for none): Enter
Set a root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] y
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…

 

 

At last MariaDB is successfully installed.

To access the MariaDB shell, run the mysql command with the -u option with sudo. For that type:
$ sudo mysql -u root

[email protected]:~$ sudo mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 58
Server version: 10.3.25-MariaDB-0ubuntu1 Ubuntu 20.10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

 

 

How to install PHP in Ubuntu 20.10?

PHP is one of the commonly used programming language for web development.
To install PHP type command:
$ sudo apt install php libapache2-mod-php php-mysql

[email protected]:~$ sudo apt 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:
libapache2-mod-php7.4 php-common php7.4 php7.4-cli php7.4-common php7.4-json php7.4-mysql php7.4-opcache php7.4-readline
Suggested packages:
php-pear
The following NEW packages will be installed:
libapache2-mod-php libapache2-mod-php7.4 php php-common php-mysql php7.4 php7.4-cli php7.4-common php7.4-json php7.4-mysql php7.4-opcache
php7.4-readline
0 upgraded, 12 newly installed, 0 to remove and 4 not upgraded.
Need to get 4,155 kB of archives.
After this operation, 18.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Type 'y' for confirmation

Now PHP is successfully installed.

After installing PHP extension, you need to restart apache to apply recent changes.For that type:
$ sudo systemctl restart apache2

[email protected]:~$ sudo systemctl restart apache2

 

If apache is working create a file named info.php to the document root /var/www/html/info.php

[email protected]:~$ sudo chmod o+w /var/www/html
[email protected]:~$ sudo cat > /var/www/html/info.php

 

Now press Ctrl + C. Then, using cat command, you could view contents written in info.php

[email protected]:~$ sudo cat /var/www/html/info.php

 

How to install phpMyAdmin in Ubuntu 20.10?

Inorder to handle the administration of MySQL/MariaDB databases, PhpMyAdmin is a free widely-used web-based graphical tool with an intuitive web interface, that supports a wide range of operations on MySQL and MariaDB is used.
Now we are going to install phpmyadmin. For that type:
$ sudo apt install phpmyadmin

[email protected]:~$ sudo apt install phpmyadmin
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
dbconfig-common dbconfig-mysql icc-profiles-free javascript-common libjs-jquery libjs-openlayers libjs-sphinxdoc libjs-underscore libonig5
libzip5 node-jquery php-bz2 php-curl php-gd php-google-recaptcha php-mbstring php-phpmyadmin-motranslator php-phpmyadmin-shapefile
php-phpmyadmin-sql-parser php-phpseclib php-psr-cache php-psr-container php-psr-log php-symfony-cache php-symfony-cache-contracts
php-symfony-expression-language php-symfony-service-contracts php-symfony-var-exporter php-tcpdf php-twig php-twig-extensions php-xml
php-zip php7.4-bz2 php7.4-curl php7.4-gd php7.4-mbstring php7.4-xml php7.4-zip
Suggested packages:
php-dbase php-libsodium php-mcrypt php-gmp php-symfony-service-implementation php-imagick php-twig-doc php-symfony-translation php-recode
php-gd2 php-pragmarx-google2fa php-samyoul-u2f-php-server
Recommended packages:
php-mcrypt php-bacon-qr-code
The following NEW packages will be installed:
dbconfig-common dbconfig-mysql icc-profiles-free javascript-common libjs-jquery libjs-openlayers libjs-sphinxdoc libjs-underscore libonig5
libzip5 node-jquery php-bz2 php-curl php-gd php-google-recaptcha php-mbstring php-phpmyadmin-motranslator php-phpmyadmin-shapefile
php-phpmyadmin-sql-parser php-phpseclib php-psr-cache php-psr-container php-psr-log php-symfony-cache php-symfony-cache-contracts
php-symfony-expression-language php-symfony-service-contracts php-symfony-var-exporter php-tcpdf php-twig php-twig-extensions php-xml
php-zip php7.4-bz2 php7.4-curl php7.4-gd php7.4-mbstring php7.4-xml php7.4-zip phpmyadmin
0 upgraded, 40 newly installed, 0 to remove and 4 not upgraded.
Need to get 15.9 MB of archives.
After this operation, 71.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

 

Type 'y' for confirmation.

During the package installation, you will be prompted to choose the web server that should be automatically configured to run PhpMyAdmin. Click enter to use Apache, the default option.
Also, PhpMyAdmin must have a database installed and configured before you can start using it. To configure a database for PhpMyAdmin with the dbconfig-common package, select yes in the next prompt.

Next, create a password for PhpMyAdmin to register with the MariaDB database server.nce the installation process is complete, the configuration files for phpMyAdmin are located in /etc/phpmyadmin and its main configuration file is /etc/phpmyadmin/config.inc.php. Another important configuration file is /etc/phpmyadmin/apache.conf, used to configure Apache2 to work with PhpMyAdmin.

To configure Apache2 to serve the phpMyAdmin site,type
$ sudo a2enconf phpmyadmin.conf

[email protected]:~$ sudo a2enconf phpmyadmin.conf
Conf phpmyadmin already enabled.

 

Then type
$ sudo systemctl reload apache2.service
and then
$ sudo apt update

[email protected]:~$ sudo systemctl reload apache2.service
[email protected]:~$ sudo apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu groovy InRelease
Get:2 https://repo.skype.com/deb stable InRelease [4,501 B]
Get:3 http://in.archive.ubuntu.com/ubuntu groovy-updates InRelease [110 kB]
Get:4 http://dl.google.com/linux/chrome/deb stable InRelease [1,811 B]
Get:5 http://packages.microsoft.com/repos/vscode stable InRelease [3,959 B]
Get:6 http://in.archive.ubuntu.com/ubuntu groovy-backports InRelease [101 kB]
Get:7 http://security.ubuntu.com/ubuntu groovy-security InRelease [110 kB]
Get:8 https://repo.skype.com/deb stable/main amd64 Packages [2,246 B]
Get:9 http://packages.microsoft.com/repos/vscode stable/main amd64 Packages [212 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu groovy-updates/main amd64 Packages [157 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu groovy-updates/main i386 Packages [62.5 kB]
Get:12 http://in.archive.ubuntu.com/ubuntu groovy-updates/main amd64 DEP-11 Metadata [15.6 kB]
Get:13 http://in.archive.ubuntu.com/ubuntu groovy-updates/universe amd64 Packages [42.9 kB]
Get:14 http://in.archive.ubuntu.com/ubuntu groovy-updates/universe i386 Packages [28.0 kB]
Get:15 http://in.archive.ubuntu.com/ubuntu groovy-updates/universe amd64 DEP-11 Metadata [10.7 kB]
Get:16 http://in.archive.ubuntu.com/ubuntu groovy-backports/universe amd64 DEP-11 Metadata [532 B]
Get:17 http://security.ubuntu.com/ubuntu groovy-security/main amd64 DEP-11 Metadata [4,688 B]
Get:18 http://dl.google.com/linux/chrome/deb stable/main amd64 Packages [1,064 B]
Get:19 http://security.ubuntu.com/ubuntu groovy-security/universe amd64 DEP-11 Metadata [1,800 B]
Fetched 871 kB in 2s (362 kB/s)
Reading package lists… Done
Building dependency tree
Reading state information… Done
4 packages can be upgraded. Run 'apt list --upgradable' to see them.

 

Now type command $ sudo apt install php-cli unzip

[email protected]:~$ sudo apt install php-cli unzip
Reading package lists… Done
Building dependency tree
Reading state information… Done
unzip is already the newest version (6.0-25ubuntu1).
unzip set to manually installed.
The following NEW packages will be installed:
php-cli
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 3,252 B of archives.
After this operation, 24.6 kB of additional disk space will be used.
Do you want to continue? [Y/n] y


Type 'y' to confirm.

At last, phpMyAdmin installed and configuration of Apache2 to serve phpMyAdmin site is done successfully.