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
<?php
phpinfo();
?>

Read More

How to Install PHP 7 on Ubuntu 18.04

Prerequisites

  • 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 Nginx on Ubuntu 18.04

Prerequisites

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

Steps to Installing Nginx on Ubuntu

Update Software Repositories

Log into your Server via SSH as the root user

ssh root@hostname

Before installing new software, it is strongly recommended to update your local software database. Updating helps to make sure you’re installing the latest and best-patched software available.

Enter the following:

sudo apt update

Allow the process to finish.

Install Nginx on Ubuntu

Enter the following to install Nginx on Ubuntu:

sudo apt install nginx

This may take some time for the system to download the software packages and install them. Allow it to complete before moving on.
Read More

How to Install MySQL 8.0 in Ubuntu 18.04

Prerequisites

  • 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 https://dev.mysql.com/get/mysql-apt-config_0.8.11-1_all.deb

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