1

I'm trying to install the latest version of Apache 2.4. However:

$ sudo apt-get install apache2=2.4.*
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Selected version '2.4.10-1ubuntu1.1~ubuntu14.04.1' (Ubuntu:14.04/trusty-backports [i386]) for 'apache2'
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 apache2 : Depends: apache2-bin (= 2.4.10-1ubuntu1.1~ubuntu14.04.1) but 2.4.7-1ubuntu4.10 is to be installed
           Depends: apache2-data (= 2.4.10-1ubuntu1.1~ubuntu14.04.1) but 2.4.7-1ubuntu4.10 is to be installed
E: Unable to correct problems, you have held broken packages.

There indeed packages for both 2.4.7 and for 2.4.10 in different repositories:

$ apt-cache policy apache2-data
apache2-data:
  Installed: (none)
  Candidate: 2.4.7-1ubuntu4.10
  Version table:
     2.4.10-1ubuntu1.1~ubuntu14.04.1 0
        100 http://archive.ubuntu.com/ubuntu/ trusty-backports/main i386 Packages
     2.4.7-1ubuntu4.10 0
        500 http://archive.ubuntu.com/ubuntu/ trusty-updates/main i386 Packages
     2.4.7-1ubuntu4.5 0
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main i386 Packages
     2.4.7-1ubuntu4 0
        500 http://archive.ubuntu.com/ubuntu/ trusty/main i386 Packages

However, I don't know how their dependencies get mixed up so that I get the error above.

1 Answer 1

3

The Backports repository is set to not be installed from in a default instance of Ubuntu (the priority of 500 is higher than 100, which is shown in your output; this has also been the standard for some time now). To make all the dependencies install from the trusty-backports repository, we have to do one of two things to make apt know what we want it to do (yes, apt and apt-get are not as smart as we would like it to be):

(1) Specify all the dependencies to install from backports, with packagename/trusty-backports which is unwieldy unless you know all the dependent packages, or the easier way...

(2) Tell apt-get when we run the command we want to specifically use backports for it as the 'target release' for installing.

sudo apt-get -t trusty-backports install apache2

This will then pull in the dependencies from the backports repository and should upgrade the Apache software accordingly.

4
  • I understand that apt doesn't use backports by default, thanks for telling me how to activate that! However, if backports isn't used by default, why does apt get confused about the versions of the dependencies? Also, I'm planning to use this in a script on both Ubuntu and Debian, is there a way that doesn't include hard-coded repository names (because these differ between the systems)? Commented Jun 27, 2016 at 13:19
  • 1
    @FlorianBrucker apt-get is being overridden with your globbing of 2.4.* which then gets the highest of the versions available - 2.4.10 in back ports. You then have to specify to permit the use of back ports. As for using a script, you will have a very bad time scripting this to first determine if Debian or Ubuntu, then handle things different for each case. I currently am stuck on a phone so I can't write more details than this, I apologize...
    – Thomas Ward
    Commented Jun 27, 2016 at 14:05
  • Is there a way to use globbing to pull 2.4.* but ignore the backports repository matches? Commented Dec 14, 2016 at 3:41
  • @CodeCommander No, not without disabling the backports repository on your system first, then running apt-get update, then attempting the install.
    – Thomas Ward
    Commented Dec 14, 2016 at 7:38

You must log in to answer this question.

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