Installation Amazon Linux AMI (EC2)

Tom Hadley edited this page Jun 7, 2017 · 20 revisions

Update (08/28/2015): On newer versions of Amazon Linux (2015.03 and above) the following command is sufficient to install node-canvas:

$ sudo yum install cairo-devel libjpeg-turbo-devel giflib-devel -y

The Amazon Linux AMI comes with old packages, e.g., Cairo 1.8.8. Here's one way to get node-canvas up and running from source.
(As of 27 March, it has 1.12.14 on my 64bit Amazon Linux 2014.09 v1.2.0)

Remove the old package:

$ sudo yum erase cairo

Set up some env vars (add to ~/.bashrc):

export PKG_CONFIG_PATH='/usr/local/lib/pkgconfig'  
export LD_LIBRARY_PATH='/usr/local/lib':$LD_LIBRARY_PATH  

Get & build various source packages in order:


$ curl -L -o libpng.tar.xz
$ tar -Jxf libpng.tar.xz && cd libpng-1.5.27/
$ ./configure --prefix=/usr/local
  (`sudo yum -y install zlib-devel` may be required before the ./configure step.)
$ make 
$ sudo make install  


$ curl -o jpegsrc.tar.gz
$ tar -zxf jpegsrc.tar.gz && cd jpeg-8d/
$ ./configure --disable-dependency-tracking --prefix=/usr/local  
$ make
$ sudo make install


$ curl -o pixman.tar.gz  
$ tar -zxf pixman.tar.gz && cd pixman-0.28.2/  
$ ./configure --prefix=/usr/local   
$ make 
$ sudo make install  


$ curl -o freetype.tar.gz
$ tar -zxf freetype.tar.gz && cd freetype-2.4.11/  
$ ./configure --prefix=/usr/local   
$ make 
$ sudo make install 


$ curl -o cairo.tar.xz  
$ tar -xJf cairo.tar.xz && cd cairo-1.12.14/  
$ ./configure --disable-dependency-tracking --without-x --prefix=/usr/local 
$ make 
$ sudo make install 

Now npm install canvas should build & run just fine.

Having trouble with GIFs?

$ sudo yum install giflib-devel

Then recompile node-canvas.