Apt 固定正在固定所有来源

Apt 固定正在固定所有来源

我已经安装了 PPA ondrej/php5,因此我可以在 Ubuntu 12.04 服务器上安装 PHP 5.5。但是,我想安装 Apache 2.2,而上述 PPA 提供了 Apache 2.4。

我创建了该文件/etc/apt/preferences.d/apache2

Package: *apache*
Pin: release o=LP-PPA-ondrej-php5
Pin-Priority: -100

相关内容来自apt-cache policy

 500 http://ppa.launchpad.net/ondrej/php5/ubuntu/ precise/main i386 Packages
     release v=12.04,o=LP-PPA-ondrej-php5,a=precise,n=precise,l=PPA for PHP5,c=main
     origin ppa.launchpad.net
 500 http://ppa.launchpad.net/ondrej/php5/ubuntu/ precise/main amd64 Packages
     release v=12.04,o=LP-PPA-ondrej-php5,a=precise,n=precise,l=PPA for PHP5,c=main
     origin ppa.launchpad.net

创建文件后,结果如下apt-cache policy apache2

apache2:
  Installed: (none)
  Candidate: (none)
  Package pin: 2.4.6-3+debphp.org~precise+1
  Version table:
     2.4.6-3+debphp.org~precise+1 -100
        500 http://ppa.launchpad.net/ondrej/php5/ubuntu/ precise/main amd64 Packages
        100 /var/lib/dpkg/status
     2.2.22-1ubuntu1.4 -100
        500 http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ precise-security/main amd64 Packages
     2.2.22-1ubuntu1 -100
        500 http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages

为什么官方 Ubuntu 存储库的优先级是-100

答案1

增加 Ubuntu 存储库中软件包的优先级:

  1. 编辑/etc/apt/preferences.d/apache2

    sudo nano /etc/apt/preferences.d/apache2
    
  2. 添加以下配置

    Package: *apache2*
    Pin: release o=ubuntu
    Pin-Priority: 1000
    
  3. 查看

    % apt-cache policy apache2                
    apache2:
      Installed: 2.4.12-2ubuntu2
      Candidate: 2.4.12-2ubuntu2
      Package pin: 2.4.12-2ubuntu2
      Version table:
         2.4.16-4+deb.sury.org~wily+4 1000
            500 http://ppa.launchpad.net/ondrej/php5/ubuntu/ wily/main i386 Packages
     *** 2.4.12-2ubuntu2 1000
            500 http://archive.ubuntu.com/ubuntu/ wily/main i386 Packages
            100 /var/lib/dpkg/status
    

相关内容