安装php5-cgi时无法安装,解决办法

最近在自家的P3机器上部署LNMP玩。ubuntu10.04图形化去掉,够实验用。在安装php5-cgi时出现以下错误(当安装php5-mysql时也同样出现):

Package php5-cgi is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package php5-cgi has no installation candidate

之前我想降级php5.2的,后来运行一个脚本后失败,再想返回php5.3出以上错误。

再来观察这个脚本:

# use karmik for php pakage
echo -e "Package: php5\nPin: release a=karmic\nPin-Priority: 991\n"  >> /etc/apt/preferences.d/php
apt-cache search php5-|grep php5-|awk ‘{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}’ >> /etc/apt/preferences.d/php
apt-cache search -n libapache2-mod-php5 |awk ‘{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}’ >> /etc/apt/preferences.d/php
exit
# add karmik to source list
sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee -a /etc/apt/sources.list.d/karmic.list
# update package database (use apt-get if aptitude crash)

大致修改了/etc/apt/下的文件,于是到该目录下:

cd /etc/apt/

rm preferences.d/*    #删除这个目录下的文件

rm sources.list.d/*     #该目录下一并删除

这时问题解决了。

注意preferences.d目录要保留,否则会出现

W: Unable to read /etc/apt/preferences.d/ – FileExists (2: No such file or directory)

这样一条警告信息。

此条目是由 malu8 发表在 未分类 分类目录的。将固定链接加入收藏夹。

评论已关闭。