nodejs 编译安装

目录

升级 gcc 到 4.8 版本

# 先安装依赖
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
tar xvf gmp-4.3.2.tar.bz2
cd gmp-4.3.2
./configure --prefix=/usr/local/gmp-4.3.2
make
make install

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
tar xvf mpfr-2.4.2.tar
cd mpfr-2.4.2
./configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2/
make
make install

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
tar xvf mpc-0.8.1.tar.gz
cd mpc-0.8.1
./configure --prefix=/usr/local/mpc-0.8.1/ --with-gmp=/usr/local/gmp-4.3.2/ --with-mpfr=/usr/local/mpfr-2.4.2
make
make install

# 编译 gcc
yum -y install glibc-devel.i686
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib 
tar -zxvf  gcc-4.8.2.tar.gz
cd gcc-4.8.2
mkdir build-gcc
cd build-gcc
../configure --prefix=/usr/local/gcc-4.8.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2
make
make install

编译 nodejs

tar xvf node-7.2.1.tar.gz
cd node-7.2.1
# 这里指定使用我们编译的 gcc 进行编译
export LD_LIBRARY_PATH=/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-4.8.2/lib:/usr/local/gcc-4.8.2/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/gcc-4.8.2/bin:$PATH 
./configure --prefix=/export/servers/node
make
make install

修改环境变量

vim /etc/profile
#加入下面代码
alias node="env LD_LIBRARY_PATH=/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-4.8.2/lib:/usr/local/gcc-4.8.2/lib64:$LD_LIBRARY_PATH /export/servers/node/bin/node"
alias npm="env LD_LIBRARY_PATH=/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-4.8.2/lib:/usr/local/gcc-4.8.2/lib64:$LD_LIBRARY_PATH /export/servers/node/bin/npm"

目录