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