- 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
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.
2. Verify PHP was installed, with the command: