composer安装依赖时报错的处理办法

近段时间经常跟composer打交道,在中间也遇到了很多的坑,这里总结一下

目录

0x01 安装时composer出现Killed,被终止

0x02 出现“Your requirements could not be resolved to an installable set of packages.”

在使用下面命令对composer.json进行安装的时候,经常会出现下面的两种种问题。

composer install

0x01 安装时composer出现Killed,被终止

情况可能是下面这个样子的

file

这种情况是由于缓存不足而造成的,在Linux中我们可以增加缓存来解决这个问题。

file

free -m
mkdir -p /var/_swap_
cd /var/_swap_
dd if=/dev/zero of=swapfile bs=1M count=2000
mkswap swapfile
swapon swapfile
echo "/var/_swap_/swapfile none swap sw 0 0" >> /etc/fstab
free -m

0x02 composer出现“Your requirements could not be resolved to an installable set of packages.”

这种报错的情况一般是这样子的

file

file

它虽然出现了"Your requirements could not be resolved to an installable set of packages.","You can also run php --ini inside terminal to see which files are used by PHP in CLI mode."这两种提示,但是这个不是我们所要关注的重点。

我们需要关注的是中间Problem提示了哪些内容

比如下面这个情况

file

在这种情况下,我们仅仅只需要安装php所对应的gd就可以解决这个报错了。

这里我用Ubuntu为例来说明,如果你安装的是php7.0的,即使用下列命令进行安装的

apt-get install php7.0

这个时候需要运行下列命令就可以安装了,就可以解决这个问题了

apt-get install php7.0-gd

下面这个例子也是一样的解决办法

file

apt-get install php7.0-mbstring

如果安装的是php7.2,这里改一下版本就可以了

apt-get install php7.2-mbstring

文章首发公众号:无心的梦呓(wuxinmengyi)

这是一个记录红队学习、信安笔记,个人成长的公众号

扫码关注即可

file

posted @ 2019-10-01 10:52  信安本原  阅读(2105)  评论(0编辑  收藏  举报