Apt pinning 是固定所有來源

Apt pinning 是固定所有來源

我已經安裝了 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
    

相關內容