41

I have Ubuntu Server 16.04 installed with Webmin 1.831. I am getting this error when trying to run PHP ERROR: Module php7.0 does not exist

libapache2-mod-php7.0 is installed.

5
  • 2
    Hi Dominic, sorry what command are you trying to run? It is missing from the question, thanks.
    – Lucio
    Commented May 7, 2017 at 2:44
  • 1
    I am running the command: a2enmod php7.0 Im trying to install ruTorrent, this requires the installation of Apache and PHP. I noticed that PHP was not working and when I run a2enmod php7.0 to verify if PHP is working I get the error above. Commented May 8, 2017 at 1:14
  • More info, when I install libapache2-mod-php7.0 I get this error: Setting up libapache2-mod-php7.0 (7.0.15-0ubuntu0.16.04.4) ... dpkg: error processing package libapache2-mod-php7.0 (--configure): subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: libapache2-mod-php7.0 E: Sub-process /usr/bin/dpkg returned an error code (1) Commented May 8, 2017 at 23:31
  • 1
    Could you please edit your post, when you want to add information? Especially file or program output listings (with the help of the {} button in the editor toolbar) will be much more readable there; alternatively you can use a pastie service for longer listings and include the link of your pastie in your question. Overall it’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks. Commented May 9, 2017 at 6:19
  • Could you please edit your question to include the full, verbatim output of sudo apt-get install -f libapache2-mod-php7.0? Thanks. Commented May 9, 2017 at 6:20

3 Answers 3

56
sudo apt purge libapache2-mod-php7.0 libapache2-mod-php

then

sudo apt install libapache2-mod-php7.0 libapache2-mod-php

fixed it.

3
  • 1
    Finally this, was that did it for me! In ubuntu 18.04 you can use php7.2 too.
    – D. Dan
    Commented Aug 16, 2018 at 12:50
  • 1
    Doesn't work for me (ubuntu 18 & php 7.2), did try php7.2, even the answers below!, looks like apache2 isn't recognize php!
    – Ibrahim.H
    Commented Jul 23, 2021 at 20:08
  • It works on Ubuntu 22.04. Thank you! Commented Dec 22, 2022 at 2:18
22

I have faced the same problem and Here is the solution:

You have to install an additional package:

sudo apt-get install libapache2-mod-php7.0

Now run

sudo a2enmod php7.0

to enable it

Restart the server

sudo systemctl restart apache2.service
9

For the latest php version as of Nov. 2020, I solved the same problem with the following commands - in that order.

$ sudo apt purge libapache2-mod-php7.4 libapache2-mod-php
$ sudo apt-get install libapache2-mod-php7.4
$ sudo a2enmod php7.4
$ sudo service apache2 stop
$ sudo service apache2 start
6
  • php7.4 doesnt exist
    – chx101
    Commented Jan 3, 2021 at 17:37
  • @chx101 apt-get install libapache2-mod-php7.4 works for me
    – barlop
    Commented Jan 3, 2021 at 19:27
  • 1
    this worked for me Jan 2021. The accepted answer did not
    – barlop
    Commented Jan 3, 2021 at 19:28
  • I am using Nginx web service. would it work for Nginx? Commented Aug 18, 2021 at 8:25
  • thanks for this. None of the above worked for me but this
    – vigamage
    Commented Jan 22, 2022 at 5:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .