kakts-log

programming について調べたことを整理していきます

Installing node.js v8.11.1 to centos 6.5 server.

Recently, Node.js v8.11.1 was released.
From this version, minimum compiler requirement(gcc) for Node.js had been updated to 4.9.4.

https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V8.md#8.11.1

In the centOS 6.5 server, default gcc package version was too old, so I had to update gcc version over 4.9.4 .

Installing devtoolset-4

To use newer gcc and other packages, Software Collections provides devtoolset for CentOS servers. Devtoolset-4 — Software Collections

In April 2018, devtoolset-4 is already ended its support, but in this post, I'll try to introduce how to install devtoolset-4.
There is also devtoolset-2 repository, but in this devtoolset-2, the version of gcc is 4.9.2. It's not applicable to node.js v8.11.1.

scl-utils package

First, to install devtoolset-4, it requires scl-utils package version above "20120927-11".
I had to set up SCL repository for centOS. repository base url is http://vault.centos.org/6.5/SCL/x86_64/

I created repository setting file to /etc/yum.repos.d/centos-scl.repo . The content of the file is as below.

[centos-scl]

name=centos-scl
baseurl=http://vault.centos.org/6.5/SCL/$basearch/
gpgcheck=0
enabled=0

After create this file, install scl-utils pakcage.

$ sudo yum install scl-utils --enablerepo=centos-scl

devtoolset-4 package

Next, set up new yum repository. mirror.centos.org provides a yum repository for Software collection packages. http://mirror.centos.org/centos/6/sclo/x86_64/rh/
In this repository, there are some versions of devtoolset. You can choose the version of it as you like.

Same as the previous chapter, it needs to set up yum repository setting. I created it to /etc/yum.repos.d/centos-devtools.repo

[centos-devtools]
name=centos-devtools
baseurl=http://mirror.centos.org/centos/6/sclo/x86_64/rh/
gpgcheck=0
enabled=0

After that, I can install some devtools-4's gcc packages for building node.js v8.11.1's native module.

$ sudo yum install devtoolset-4-gcc devtoolset-4-gcc-c++ devtoolset-4-binutils --enablerepo=centos-devtools

Finally, checking the scl list. If devtoolset-4 in the scl list, it's okay to use newer gcc.

$ scl -l

devtoolset-2
devtoolset-4

By enabling devtoolset-4, I was finally able to use newer gcc.

$ scl enable devtoolset-4 bash

$ gcc --version
gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)

Copyright (C) 2015 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.