apt-get install php 指定版本号,如何使用apt-get升级单个软件包?
問題描述
我如何更新單個軟件包?至于man apt-get表示apt-get upgrade不會將軟件包/軟件包列表作為參數:
upgrade
upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available.
最佳解決辦法
你只需要做apt-get install --only-upgrade 。這將僅升級該單個軟件包,并且僅在已安裝時才升級。
如果您希望在不存在該軟件包的情況下安裝該軟件包,或者如果該軟件包進行了升級,則可以省略--only-upgrade。
次佳解決辦法
為了使用CLI更新單個軟件包:
sudo apt-get install --only-upgrade
例如sudo apt-get install --only-upgrade ack
Reading package lists... Done
Building dependency tree
Reading state information... Done
Skipping **ack**, it is not installed and only upgrades are requested.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
第三種解決辦法
我可以想到兩種可能的方式:
sudo apt-get install nameofpackage
即使已經安裝,這將升級包:
~$ sudo apt-get install emesene
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
emesene
1 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Need to get 1,486 kB of archives.
After this operation, 696 kB disk space will be freed.
Get:1 http://il.archive.ubuntu.com/ubuntu/ natty-updates/universe emesene all 2.11.4+dfsg-0ubuntu1 [1,486 kB]
使用Synaptic Package Manager:右鍵單擊→標記以進行升級:注意:有時它可能會要求額外的軟件包或依賴項,這是正常的。
第四種辦法
根據我在Ubuntu 12.04 LTS上的經驗,如果使用單獨的PPA,使用下面的命令不會升級軟件包 –
sudo apt-get --only-upgrade install
同樣,我不想運行升級命令,它會升級服務器上的所有軟件包 –
sudo apt-get dist-upgrade
例如,我安裝了PHP 5.3,并已將ondrej PPA添加到我的apt.sources中,方法是使用 –
sudo add-apt-repository ppa:ondrej/php5
如果我跑步
sudo apt-get install php5
它只會重新安裝PHP 5.3。
我必須首先確定要升級到的版本號
sudo apt-cache policy php5
這將列出所有可用的版本號。您應該找到要升級到的版本號,然后復制引用它的整個字符串。例如,Ubuntu上PHP 5.5的字符串是“5.5.16 + dfsg-1 + deb.sury.org?precise + 2”。
現在,您可以運行帶有特定版本號的apt-get安裝命令,瞧!
sudo apt-get install php5=5.5.16+dfsg-1+deb.sury.org~precise+2
我只是添加了這個,因為我無法在其他地方找到這些信息!
第五種辦法
在Ubuntu 9.04 Jaunty上,
apt-get --only-upgrade install
收益率:
E: Sense only is not understood, try true or false.
命令
apt-get --only-upgrade true install
在我的情況下工作。
第六種辦法
對于如果命令行解決方案尚不存在的情況下不安裝它的命令行解決方案:
dpkg -s 2>/dev/null | grep -q Status.*installed && sudo apt-get install
這可以很容易地制成一個腳本,例如:
upgrade-package.sh:
#!/bin/bash
[[ -z $1 ]] && { echo "Usage: $(basename $0) package"; exit 1; }
if dpkg -s "$1" 2>/dev/null | grep -q Status.*installed; then
echo "Attempting to upgrade $1"
sudo apt-get install "$1"
else
echo "Package $1 is not installed"
fi
參考資料
總結
以上是生活随笔為你收集整理的apt-get install php 指定版本号,如何使用apt-get升级单个软件包?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java什么是局部变量,什么是java的
- 下一篇: php乱炖,linux使用crontab