1

I'm a newbie and I messed up with a server trying to reinstall apache2 and php, I did extensive searches inside this forum and in the interwebs but no solution for similar problems helped me. At the moment my web server downloads files instead of opening the web pages so i'm trying to clean up my php installation, I think I messed up my package list or php installation.

apt-get install php5

    # apt-get install php5Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 php5 : Depends: libapache2-mod-php5 (>= 5.3.10-1ubuntu3.25) but it is not going to be installed or
                 libapache2-mod-php5filter (>= 5.3.10-1ubuntu3.25) but it is not going to be installed or
                 php5-cgi (>= 5.3.10-1ubuntu3.25) but it is not going to be installed or
                 php5-fpm (>= 5.3.10-1ubuntu3.25) but it is not going to be installed
        Depends: php5-common (>= 5.3.10-1ubuntu3.25) but it is not going to be installed
 php5.6-fpm : Depends: php5.6-common (= 5.6.26-1+deb.sury.org~precise+1) but 5.6.26-2+deb.sury.org~precise+1 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

apt-get install php

# apt-get install phpReading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 php : Depends: php7.0 but it is not going to be installed
 php5.6-fpm : Depends: php5.6-common (= 5.6.26-1+deb.sury.org~precise+1) but 5.6.26-2+deb.sury.org~precise+1 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

apt-get -f install

# apt-get -f installReading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  php5.6-fpm
Suggested packages:
  php-pear
The following packages will be upgraded:
  php5.6-fpm
1 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1569 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
dpkg: dependency problems prevent configuration of php5.6-fpm:
 php5.6-fpm depends on php5.6-common (= 5.6.26-1+deb.sury.org~precise+1); however:
  Version of php5.6-common on system is 5.6.26-2+deb.sury.org~precise+1.
dpkg: error processing php5.6-fpm (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                       Errors were encountered while processing:
 php5.6-fpm
E: Sub-process /usr/bin/dpkg returned an error code (1)

any help will be appreciated.

SOLUTION:

sudo dpkg --remove --force-depends php5.6*
sudo apt-get autoclean
sudo apt-get install php php5.6

looks like the problem is solved, I'm not 100% sure because my web server still doesn't interpret php but I'm not getting those pesky installation errors anymore.

0

Open terminal and type

  sudo dpkg --configure -a

If it doesn't help then do this

  sudo apt autoremove <packagename>

If this doesn't help then you Need an internet connection.Type in terminal

  sudo apt-get autoclean

remove sources.list file.and create new sources.list...

sudo rm /etc/apt/sources.list 

Then, type in

sudo software-properties-gtk 

enter image description here This will open software-properties-gtk and a newsources.list will be created automatically.

Then change the server to US or to any other server of your choice. You must enable repositories from the new dialog in order to create new sources.list.

Tick all the boxes then click on Revert then click close.

Need to restore default repositories

 sudo apt-get update && sudo apt-get dist-upgrade -y

(it is good practice to backup this file before installing to recover if such things happen)

Now install anything!

UPDATE :

 sudo apt-get autoclean
 sudo dpkg --remove --force-depends   *put here all the things which are listed in ur Depends: *
  sudo apt-get install -f

Update 2: Create a dummy initscript to fool dpkg:(use nano/gedit/vim)

 sudo nano /etc/init.d/php5.6-fpm

Enter the following:

 #!/bin/bash
  exit 0

Save the file, set execution permission (sudo chmod 755 /etc/init.d/php5.6-fpm) and try to sudo apt-get remove php5.6-fpm again. Dot this for all packages.

  • sadly i don't have software-properties-gtk and can't apt-get install it because i get that same error, also i'm connecting via ssh – Riccardo Oct 11 '16 at 6:33
  • 'Did u try sudo apt install --reinstall package – minigeek Oct 11 '16 at 6:38
  • # apt-get install --reinstall software-properties-gtk Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package software-properties-gtk – Riccardo Oct 11 '16 at 7:17
  • Nahh..not software properties..put the packages which are giving errors... like put apache2 php... Whichever u were installing – minigeek Oct 11 '16 at 7:19
  • same error: E: Unable to locate package php5. Probably because i removed source.list ? – Riccardo Oct 11 '16 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.