Prerequisites
Update the installed packages.
apt update
Install the Ondřej PHP repository.
apt install software-properties-commonsudo add-apt-repository ppa:ondrej/php apt update
Check that the repositories are correctly installed.
grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/*
Step 1 – Install Apache
apt install apache2