With the release of Ubuntu 20.04 LTS, things have become pretty susceptible and favorable for
the developers. LAMP is an open-source software that is usually installed to facilitate server
host vibrant websites and web applications that are written in PHP. In this manual, we'll tell you
everything you need to know about installing a LAMP stack on Ubuntu 20.04.
Requirements: You must have the Ubuntu 20.04 server. For this procedure to complete, you
require the non-root Ubuntu service with a sudo-facilitated user account along with a
fundamental firewall. Check out our guide to Initial server setup for Ubuntu 20.04 in case you
are not familiar with what it is.
Step 1: Apache Installation and Firewall Update
Being the most popular web server on the planet, Apache is a well-detailed server. It
encompasses an active community of users and is being used widely for a long time in history.
Thus, it has been known to become the most preferred choice of the developers.
To install Apache, use the following commands:
$ sudo apt update
$ sudo apt install apache2
If you haven't used sudo before this session, the server will instruct you to submit your
password to confirm that you possess the correct privileges as required to organize the system
packages with apt.
To substantiate the installation of Apache, you must press Y, followed by ENTER.
This leads to the completion of the installation. Now you require the firewall settings to be
adjusted properly so that you can allow HTTP traffic. UFW, however, has a distinct appeal form
that one can leverage to complete that. If you wish to run all of the presently accessible UFW
application profiles, run the following:
$ sudo ufw app list
Output like this will be displayed:
Available applications:
Apache
Apache Full
Apache Secure
OpenSSH
Let us see what these profiles actually mean:
● Apache: This profile is used to open port 80 only (ordinary, unencrypted web
traffic).
● Apache Full: this one is required to open both port 80 and 443 (TLS/SSL
encrypted traffic).
● Apache secure: This one, in contrast, opens only port 443.
As of now, allowing port 80 only for the connections is the most adequate choice since there is
a lack of a TLS/SSL certificate in the initial Apache installation.
Allow the traffic on port 80 using the following Apache profile:
$ sudo ufw allow in "Apache"
Output:
Status: active
To Action From
OpenSSH. ALLOW Anywhere
Apache ALLOW Anywhere
OpenSSH (v6)ALLOW Anywhere(v6)
Apache(v6) ALLOW Anywhere(v6)
The traffic on port 80 is allowed to do this.
To do a spot check, run:
http://your_server_ip
This will lead you to a web page that defaults on Ubuntu 20.04 Apache.
This web page is a sign of the correct installation of the web server.
Step 2: My SQL Installation
Once the web server is installed successfully, install the database system to have access to the
storage for your site. For this purpose, what could be better than My SQL? It's a popular
database management system that is utilized in PHP environments.
Use the following:
$ sudo apt install mysql-server
When instructed so, confirm installation by simply pressing the Y key followed by ENTER.
On completion of installation, you are advised to run a security script that has been provided as
a pre-installation on MySQL. This step will help you remove any insecurities in your database
system.
$ sudo MySQL_secure_installation
This leads you to a question of Validation.
VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks
the strength of the password and allows the users to set only those passwords that are secure
enough. Would you like to set up a VALIDATE PASSWORD plugin?
Press y|Y for “Yes,” any other key for “No”:
A yes response will direct you to select a level of password validation.
Once down with the validation, test out the login processor MySQL by:
$ sudo mysql
To exit this console, type:
mysql> exit
Step 3: Installation of PHP
Now, let us first revise the steps. Apache for surveying the content has been installed, MySQL
for database management is also done and dusted. The next step is to install the PHP
component; this one processes the code, thereby displaying vibrant content to the end-user.
To install these packages, run:
$ sudo apt install php libapache2-mod-php-mysql
This sets up your installation. Now you can try out the PHP confirmation:
$ php -v
Output:
PHP 7.4.3 (cli) ( built: Jun 18 2021 20:26: 18 (NTS)
Copyright © The PHP Group
Zend Engine v3.4.0, Copyright © Zend technologies
with Zend OPcache v7.4.3, Copyright © Zend technologies
This step concludes your LAMP stack installation completely. Now the LAMP stack is
operational in your Ubuntu 20.04.
To know more: https://www.e2enetworks.com/cloud-credits-request-sk/