Unable to locate package libapache2-mod-php7

At the time of the post Ubuntu 16.04 was one of the newer versions and as such the packages changed to php7.0 but as time goes on it will be 7.1 to 7.2 etc... and I don't have the time to figure out what was the latest package and I'm not dependent on a specific version. So if you want the latest version of packages to install without having to know the correct version number just drop the version number and the latest applicable to the distribution you are using will be installed. In my case I was using Ubuntu 17.10 and the php version is different so I used the following command line to get the latest.

sudo apt-get install apache2 php-mysql libapache2-mod-php mysql-server

It installed php 7.1 and all of the correct dependencies.

So if you don't require a specific version but just want the latest that works with the distribution drop the version number and use the command line above.


The name of the package is libapache2-mod-php7.0 Try again by having that .0 at the end and it should work.


On Ubuntu 18.04, I had to add the repository below first. Once the repo was added I was able to install the php7.x items.

sudo add-apt-repository ppa:ondrej/php

Source: https://websiteforstudents.com/apache2-with-php-7-1-support-on-ubuntu-18-04-lts-beta-server/


If you are using Ubuntu 17.04/17.10 or above use php7.1 instead of 7.0 since it is no longer available.

sudo apt-get install php7.1