How to Install a LAMP Stack on Ubuntu 18.04

What is a LAMP Stack?

A LAMP (Linux, Apache, MySQL, PHP) stack is a common, free, and open-source web stack used for hosting web content in a Linux environment. Many consider it the platform of choice on which to develop and deploy high-performance web apps.
This guide shows how to install and test a LAMP stack on Ubuntu 18.04 (LTS).

Install LAMP Ubuntu 18.04

Using the tasksel command the procedure of installing LAMP on Ubuntu 18.04 Bionic Beaver is a rather trivial matter. First, make sure that you have the tasksel package installed:

$ sudo apt install tasksel

To install LAMP server using tasksel execute:

$ sudo tasksel install lamp-server

Test your LAMP Install

Create a simple PHP Info page to test your LAMP installation:

$ sudo bash -c "echo -e '<?php\nphpinfo();\n?>' > /var/www/html/phpinfo.php"

The above command will create a new /var/www/html/phpinfo.php file with the following content:

$ cat /var/www/html/phpinfo.php

Read More

How to Install PHP 7 on Ubuntu 18.04


  • Access to an Ubuntu user account with sudo privileges
  • Access to a command line/terminal window (Ctrl-Alt-T)
  • A running web server (Apache or Nginx)

Installing PHP 7 on Ubuntu

Like many developer tools, PHP has several different release versions.
By default, PHP 7.2 is included in Ubuntu 18.04. At the time of writing, PHP 7.3.1 was released. It was tagged as a release of a “stable” version of the software. A stable release is well-tested and is designed to be used and supported for a longer period

How to Install PHP 7.2 with Apache on Ubuntu

Update Ubuntu

Ensure you are using the latest Ubuntu updates by entering the following command into a terminal window:

sudo apt update && sudo apt upgrade

Install PHP 7.2

1. To install PHP 7.2, enter the following command:

sudo apt install php libapache2-mod-php

Confirm the installation by hitting Enter. The system will download and install PHP from the software repositories. This command also installs dependencies and modules for use with Apache.

installing PHP dependencies and modules for use with Apache

2. Verify PHP was installed, with the command:

php -v
verification PHP 7.2 was installed successfully on Ubuntu

Read More

How to Install MySQL 8.0 in Ubuntu 18.04


  • A system running Ubuntu 18.04
  • Access to a user account with sudo privileges

Installing MySQL in Ubuntu Using Terminal

This guide assumes you’re installing to a local system. If you need to set up encryption or security certificates for configuring a remote server, please refer to this guide.

Step 1: Enable MySQL Repositories

Your installation of Ubuntu 18.04 may not have access to MySQL repositories.
To download the latest repositories, enter:

wget -c

The system should respond by reaching out to the server and downloading the .deb configuration file. A progress bar displays to let you know when the download is completed.

Terminal command to install and add the MySQL repository.

Step 2: Install MySQL Repositories

To install and enable MySQL repositories, enter the command:

sudo dpkg -i mysql-apt-config_0.8.11-1_all.deb

The system should respond by launching an installation configuration tool. It will present options to you for which MySQL version you want to install.

MySQL package configuration manager

Leave the default settings and click OK, unless you’re an advanced user and have a specific reason to change them.

Step 3: Refresh the Repositories

Any time you’re installing new packages, you should update repository listings to ensure you are installing the latest release.
In the terminal, enter the following:

sudo apt-get update

The system should take a few moments and refresh the repository cache.

Step 4: Install MySQL

To install MySQL on Ubuntu, run the command:

sudo apt-get install mysql-server

Enter your administrator credentials, and the system will install the MySQL server package, client packages, and database common files.

Terminal command and output installing MySQL

The installation will prompt you to enter and confirm a root user and password for the MySQL database.
This password grants total access to the database, so it should be secure and private.
Next, the installer will display a notice about a new authentication method. The newer authentication is more secure but may cause compatibility problems with older MySQL clients.
Read More

How to Install Apache on Ubuntu 18.04


  • A system running Ubuntu 18.04 LTS (Bionic Beaver)
  • An internet connection
  • Access to a user account with sudo privileges

How to Install Apache on Ubuntu

Before installing new software, it’s a good idea to refresh your local software package database to make sure you are accessing the latest versions. This helps cut down on the time it takes to update after installation, and it also helps prevent zero-day exploits against outdated software.
Open a terminal and type:

sudo apt-get update

Let the package manager finish updating.

Step 1: Install Apache

To install the Apache package on Ubuntu, use the command:

sudo apt-get install apache2

The system prompts for confirmation – do so, and allow the system to complete the installation.

Terminal command to install Apache on Ubuntu.

Step 2: Verify Apache Installation

To verify Apache was installed correctly, open a web browser and type in the address bar:


The web browser should open a page labeled “Apache2 Ubuntu Default Page,” as in the image below:

apache2 the default welcome page on ubuntu

Note: Replace local.server.ip with the IP address of your server. If you are unsure what’s the IP address, run the following terminal command:

hostname -I | awk '{print $1}'

The output will return your server’s IP address.

Step 3: Configure Your Firewall

Although the Apache installation process is complete, there is one more additional step. Configure the default UFW firewall to allow traffic on port 80.
Start by displaying available app profiles on UFW:

sudo ufw show app list

The terminal should respond by listing all available application profiles, as seen in the example below.

Available applications:
  Apache Full
  Apache Secure

Use the following command to allow normal web traffic on port 80:

sudo ufw allow 'Apache'
Image of how Apache traffic is allowed in Ubuntu terminal.

Verify the changes by checking UFW status:

sudo ufw status
Check UFW status and verify that Apache traffic is allowed.

If you have other applications or services to allow, make sure you configure your firewall to allow traffic. For example, using the sudo ufw allow 'OpenSSH' command will enable secure, encrypted logins over the network.

Read More