When I try to install the GD Library for PHP on my TurnKey LAMP appliance, I get the following message:
root@lamp ~# apt-get install php5-gd Reading package lists... Done Building dependency tree Reading state information... Done php5-gd is already the newest version. You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: php5-gd : Depends: libgd2-xpm (>= 2.0.36~rc1~dfsg) but it is not going to be installed Depends: libjpeg8 (>= 8c) but it is not going to be installed Depends: libpng12-0 (>= 1.2.13-4) but it is not going to be installed Depends: libx11-6 but it is not going to be installed Depends: libxpm4 but it is not going to be installed Depends: phpapi-20100525+lfs but it is not installable Depends: php5-common (= 5.4.4-14) but 5.3.3-7+squeeze14 is to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Then, when I try to use the ‘apt-get -f install’ option, I get this:
root@lamp ~# apt-get -f install Reading package lists... Done Building dependency tree Reading state information... Done Correcting dependencies... Done The following extra packages will be installed: fontconfig-config libfontconfig1 libgd2-xpm libjpeg62 libpng12-0 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxpm4 ttf-dejavu-core Suggested packages: libgd-tools The following packages will be REMOVED: php5-gd The following NEW packages will be installed: fontconfig-config libfontconfig1 libgd2-xpm libjpeg62 libpng12-0 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxpm4 ttf-dejavu-core 0 upgraded, 12 newly installed, 1 to remove and 33 not upgraded. Need to get 0 B/3557 kB of archives. After this operation, 8569 kB of additional disk space will be used. Do you want to continue [Y/n]? Y [master e6f9b93] saving uncommitted changes in /etc prior to apt run Author: root <root@lamp> 1 files changed, 1 insertions(+), 1 deletions(-) rewrite webmin/system-status/info (100%) debconf: delaying package configuration, since apt-utils is not installed (Reading database ... 25484 files and directories currently installed.) Removing php5-gd ... /var/lib/dpkg/info/php5-gd.prerm: 11: php5dismod: not found dpkg: error processing php5-gd (--remove): subprocess installed pre-removal script returned error exit status 127 configured to not write apport reports Processing triggers for libapache2-mod-php5 ... Reloading web server config: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName . Errors were encountered while processing: php5-gd Counting objects: 1469, done. Compressing objects: 100% (957/957), done. Writing objects: 100% (1469/1469), done. Total 1469 (delta 123), reused 1460 (delta 119) E: Sub-process /usr/bin/dpkg returned an error code (1)
Any ideas? Thanks.
It looks like your Debian-based system is missing some files that were installed with third party packages from third party repositories, and a lot of things are out of sync.
Your immediate problem is:
/var/lib/dpkg/info/php5-gd.prerm: 11: php5dismod: not found
You can work around this by editing the file
/var/lib/dpkg/info/php5-gd.prerm, removing its entire contents and replacing it with:
#!/bin/sh set -e
At this point, run
apt-get install -f again.
After this completes successfully, to get your system back in sync, run:
apt-get update && apt-get dist-upgrade
Once that completes successfully, you can reinstall the php5-gd package.
apt-get install php5-gd
In future, be careful with manually removing files included with system packages, be careful with which third party repositories you use, and be especially careful if you mix packages from different Debian versions (e.g. stable and testing).
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.