给linux 换上163的源
有一种错误叫做:
Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package cairo
上面出现的情况是阿里云环境安装图形组件 cairo 时出现错误(可以使用ccap代替生成验证码),在很多开源的LInux 内核系统下图形处理大多依赖此组件.出现上面的错误是因为nodeJS 环境下 sudo npm install canvas 时,系统需要依赖 cairo,而服务器没有/找不到.
所以用脚趾头稍微想了想便直接敲下了
sudo apt-get install cairo
结果就是开头出现的错误,瞬间迷茫了.
各种 google Unable to locate package
从大多数已经碰到此错误的答案中看到一个共同的描述: 更新 apt-get 源,重新安装.
但是介于我们欠发达的网络还要翻越大洋去米国下载东东,何不用我们自己的 163 源.
如何更换源?
其实就是将网易提供的源加到我们的源文件
nano /etc/apt/sources.list
把下面的源地址列表添加到 sources.list 头部
#add by Crifan Li 2013-08-08, added 163 source deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
保存 sources.list 并退出,然后执行
sudo apt-get update
满屏幕类似黑客帝国的编码飞过...........证明你更新成功.
打开 cairo 官网 http://cairographics.org/download/
按照描述执行shell 如下:
sudo apt-get install libcairo2-dev
又是满屏字符飞过......
这是再去 sudo npm install canvas 时,顺利执行成功.