Cannot install php on Ubuntu 16.04 LTS

9,350

OK I found a solution that worked for me...

cd /var/lib/dpkg/info
rm *.postinst
apt-get --force-yes install openjdk-7-jre-headless

I only assume that as openjdk was already installed that this was just a kick it need not have been openjdk.

I then proceded to purge apache and php

apt-get purge apache2
apt-get purge php
apt-get autoremove
apt-get autoclean
rm -R /etc/apache2 /etc/php

I could then cleanly install apache2 and php once more and everything was happy apt-get install apache2 apt-get install php

What a headache. dpkg --configure -a did nothing and kept saying the initial dependecy error as did every other solution i could find.

Share:
9,350

Related videos on Youtube

John
Author by

John

Updated on September 18, 2022

Comments

  • John
    John over 1 year
    Creating config file /etc/php/7.0/cli/php.ini with new version
    Setting up php7.0-fpm (7.0.8-0ubuntu0.16.04.3) ...
    Not replacing deleted config file /etc/php/7.0/fpm/php.ini
    insserv: warning: script 'K01jira' missing LSB tags and overrides
    insserv: warning: script 'nagios' missing LSB tags and overrides
    insserv: warning: script 'jira' missing LSB tags and overrides
    Job for php7.0-fpm.service failed because the control process exited with error code. See "systemctl status php7.0-fpm.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript php7.0-fpm, action "start" failed.
    dpkg: error processing package php7.0-fpm (--configure):
     subprocess installed post-installation script returned error exit status 1
    dpkg: dependency problems prevent configuration of php7.0:
     php7.0 depends on php7.0-fpm | libapache2-mod-php7.0 | php7.0-cgi; however:
      Package php7.0-fpm is not configured yet.
      Package libapache2-mod-php7.0 is not installed.
      Package php7.0-cgi is not installed.
    
    dpkg: error processing package php7.0 (--configure):
     dependency problems - leaving unconfigured
    dpkg: dependency problems prevent configuration of php:
     php depends on php7.0; however:
      Package php7.0 is not configured yet.
    
    dpkg: error processing package php (--configure):
     dependency problems - leaving unconfigured
    No apport report written because the error message indicates it's a follow-up error from a previous failure.
        No apport report written because the error message indicates it's a follow-up error from a previous failure.
            Errors were encountered while processing:
     php7.0-fpm
     php7.0
     php
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    I just upgraded from Ubuntu 14.04 to 16.04. Before doing so we completely removed mysql and php with the mindset of installing the new version afterward.

    We installed a fresh apache and mysql server with zero issue. But when it comes to php we keep getting stuck with the above warning.

    The guide we just followed was https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

    How to resolve this issue and install php?

    • sinclair
      sinclair over 7 years
      Try dpkg --configure -a
    • Lynob
      Lynob over 7 years
      @sinclair I flag many questions without hesitations because I'm not a nice guy. Maybe there's a dupe for this a question but I don't think the one you pointed to is the right dupe for this one
    • David Foerster
      David Foerster over 7 years
      To quote your question: See "systemctl status php7.0-fpm.service" and "journalctl -xe" for details. – What's the output of those?
  • Der Alex
    Der Alex over 3 years
    Thanks for your solution! I just had a similar problem and removing .postinst and kickstarting apt helped me out!