我正在安装 php gd5 组件,但出现了一些不寻常的错误,我不明白为什么。它在我的本地服务器上运行良好,但在 VPS 上我遇到了这个问题。
命令如下:
apt-get 安装 php5-gd
错误如下:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
php5-gd : Depends: libgd3 (>= 2.1.0~alpha~) but it is not going to be installed
Depends: phpapi-20121212
Depends: php5-common (= 5.5.9+dfsg-1ubuntu4.14) but 5.6.14+dfsg-1+deb.sury.org~precise+1 is to be installed
php5-imagick : Depends: libmagickcore4 (>= 8:6.6.9.7) but it is not installable
Depends: libmagickwand4 (>= 8:6.6.9.7) but it is not installable
Depends: phpapi-20100525 but it is not installable
Recommends: ghostscript
Recommends: ttf-dejavu-core but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
尝试使用 apt-get -f 后我得到的结果如下:
apt-get -f 安装 php5-gd
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
php5-gd : Depends: libgd3 (>= 2.1.0~alpha~) but it is not going to be installed
Depends: phpapi-20121212
Depends: php5-common (= 5.5.9+dfsg-1ubuntu4.14) but 5.6.14+dfsg-1+deb.sury.org~precise+1 is to be installed
php5-imagick : Depends: libmagickcore4 (>= 8:6.6.9.7) but it is not installable
Depends: libmagickwand4 (>= 8:6.6.9.7) but it is not installable
Depends: phpapi-20100525 but it is not installable
Recommends: ghostscript
Recommends: ttf-dejavu-core but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
运行 apt-get -f install (无包)
apt-get -f 安装
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
php5-imagick
0 upgraded, 0 newly installed, 1 to remove and 111 not upgraded.
1 not fully installed or removed.
After this operation, 476 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 73412 files and directories currently installed.)
Removing php5-imagick (3.1.0~rc2-1~precise+1) ...
sed: can't read /etc/php5/conf.d/imagick.ini: No such file or directory
dpkg: error processing package php5-imagick (--remove):
subprocess installed post-removal script returned error exit status 2
Errors were encountered while processing:
php5-imagick
E: Sub-process /usr/bin/dpkg returned an error code (1)
有人知道如何解决这些问题吗?
尝试了其他一些方法后:
root@vps:~# mkdir /etc/php5/conf.d/
root@vps:~# touch /etc/php5/conf.d/imagick.ini
root@vps:~# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
php5-imagick
0 upgraded, 0 newly installed, 1 to remove and 111 not upgraded.
1 not fully installed or removed.
After this operation, 476 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 73398 files and directories currently installed.)
Removing php5-imagick (3.1.0~rc2-1~precise+1) ...
root@vps:~# apt-get install php5-gd
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php5-gd : Depends: phpapi-20121212
Depends: php5-common (= 5.5.9+dfsg-1ubuntu4.14) but 5.6.14+dfsg-1+deb.sury.org~precise+1 is to be installed
E: Unable to correct problems, you have held broken packages.
当我安装它所说的内容时,我没有得到安装候选项。
谢谢
答案1
这些错误通常(如果没有apt-cache policy
丢失包就很难说)表现为:
完全不使用 PPA,检查是否
/etc/apt/sources.list.d/
包含该ondrej-php5-5_6-trusty.list
文件并且它不为空或被注释掉。如果该文件不存在,则应使用以下命令将其添加回来sudo add-apt-repository ppa:ondrej/php5-5.6
并正常进行。使用 PPA 中不支持的架构。我认为这是您的情况,VPS 在 Raspberry Pi 2 或 3 上运行。
armhf
最近才对ppa:ondrej/php5
和添加了支持ppa:ondrej/php5-5.6
,因此可能仍有一些软件包未重新编译,并且arm64
(对于 RPi 3)尚未启用。我将arm64
在这两个 PPA 中启用架构,但重新编译所有内容需要一些时间。
答案2
好的,最后解决了这个问题: https://stackoverflow.com/questions/30285453/error-installing-php5-mcrypt
sudo add-apt-repository -r ppa:ondrej/php5
sudo add-apt-repository -r ppa:ondrej/php5-oldstable
sudo add-apt-repository -r ppa:ondrej/php5-5.6
sudo apt-get purge php5* apache2* mcrypt*
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5 php5-mcrypt php5-curl apache2
sudo php5enmod mcrypt
sudo php5enmod curl
sudo apt-get install php5-gd
感谢每一位帮助过我的人。