apt-get install php 指定版本号,如何使用apt-get升级单个软件包?
問(wèn)題描述
我如何更新單個(gè)軟件包?至于man apt-get表示apt-get upgrade不會(huì)將軟件包/軟件包列表作為參數(shù):
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 。這將僅升級(jí)該單個(gè)軟件包,并且僅在已安裝時(shí)才升級(jí)。
如果您希望在不存在該軟件包的情況下安裝該軟件包,或者如果該軟件包進(jìn)行了升級(jí),則可以省略--only-upgrade。
次佳解決辦法
為了使用CLI更新單個(gè)軟件包:
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
即使已經(jīng)安裝,這將升級(jí)包:
~$ 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:右鍵單擊→標(biāo)記以進(jìn)行升級(jí):注意:有時(shí)它可能會(huì)要求額外的軟件包或依賴項(xiàng),這是正常的。
第四種辦法
根據(jù)我在Ubuntu 12.04 LTS上的經(jīng)驗(yàn),如果使用單獨(dú)的PPA,使用下面的命令不會(huì)升級(jí)軟件包 –
sudo apt-get --only-upgrade install
同樣,我不想運(yùn)行升級(jí)命令,它會(huì)升級(jí)服務(wù)器上的所有軟件包 –
sudo apt-get dist-upgrade
例如,我安裝了PHP 5.3,并已將ondrej PPA添加到我的apt.sources中,方法是使用 –
sudo add-apt-repository ppa:ondrej/php5
如果我跑步
sudo apt-get install php5
它只會(huì)重新安裝PHP 5.3。
我必須首先確定要升級(jí)到的版本號(hào)
sudo apt-cache policy php5
這將列出所有可用的版本號(hào)。您應(yīng)該找到要升級(jí)到的版本號(hào),然后復(fù)制引用它的整個(gè)字符串。例如,Ubuntu上PHP 5.5的字符串是“5.5.16 + dfsg-1 + deb.sury.org?precise + 2”。
現(xiàn)在,您可以運(yùn)行帶有特定版本號(hào)的apt-get安裝命令,瞧!
sudo apt-get install php5=5.5.16+dfsg-1+deb.sury.org~precise+2
我只是添加了這個(gè),因?yàn)槲覠o(wú)法在其他地方找到這些信息!
第五種辦法
在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
在我的情況下工作。
第六種辦法
對(duì)于如果命令行解決方案尚不存在的情況下不安裝它的命令行解決方案:
dpkg -s 2>/dev/null | grep -q Status.*installed && sudo apt-get install
這可以很容易地制成一個(gè)腳本,例如:
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
參考資料
總結(jié)
以上是生活随笔為你收集整理的apt-get install php 指定版本号,如何使用apt-get升级单个软件包?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: java什么是局部变量,什么是java的
- 下一篇: 波场php转,波场TRC20 Token