centos 6.5安装nodejs全记录

下载node源码

cd /usr/local/src
curl https://nodejs.org/dist/v6.11.4/node-v6.11.4.tar.gz -o ./node-v6.11.4.tar.gz
tar -xzvf node-v6.11.4.tar.gz
cd node-v6.11.4

安装

如果没安装python,先安装python,否则会报错,如下

./configure --prefix=/usr/local/node/6.11.4
which: no python2.7 in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
WARNING: failed to autodetect C++ compiler version (CXX=g++)
WARNING: failed to autodetect C compiler version (CC=gcc)
Node.js configure error: No acceptable C compiler found!

        Please make sure you have a C compiler installed on your system and/or
        consider adjusting the CC environment variable if you installed
        it in a non-standard prefix.

Linux上安装Node.js需要安装Python 2.6 或 2.7 ,不建议安装Python 3.0以上版本。

安装python2.7

下载python2.7.14

cd /usr/local/src
curl https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz -o python-2.7.14.tgz

setup compilation:

cd python-2.7.14
./configure --prefix=/usr/local/python/2.7.14
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python2.7... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux2
checking EXTRAPLATDIR...
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/Python-2.7.14':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

报错是因为没依赖库,执行下面的命令

yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

再次

./configure --prefix=/usr/local/python/2.7.14

编译:

make

安装:

make install

建立链接,方便使用:

ln -s /usr/local/python/2.7.14/bin/python2.7 /usr/bin/python
ln -s /usr/local/python/2.7.14/bin/python2.7 /usr/bin/python2
ln -s /usr/local/python/2.7.14/bin/python2.7 /usr/bin/python2.7

查看版本号

python --version

继续安装node

cd /usr/local/src/node-v6.11.4
./configure --prefix=/usr/local/node/6.11.4
yum upgrade gcc-c++
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

解决方法:

vim /usr/bin/yum
// 首行改为
#!/usr/bin/python2.6

如果出现下面的错误

./configure --prefix=/usr/local/node/6.11.4
WARNING: C++ compiler too old, need g++ 4.8 or clang++ 3.4.2 (CXX=g++)
creating ./icu_config.gypi
* Using ICU in deps/icu-small

更换yum源

首先备份/etc/yum.repos.d/CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)

CentOS7
CentOS6
CentOS5
运行以下命令生成缓存

yum clean all
yum makecache
参考
http://mirrors.163.com/.help/centos.html

但是yum上最新版本是gcc-c++-4.4.7-18.el6.x86_64,改为源码安装(gcc需要翻墙,以后补充)
这里安装clang++

先安装cmake

yum install cmake

下载源代码

curl http://releases.llvm.org/3.4.2/llvm-3.4.2.src.tar.gz -o llvm.tar.gz
curl http://releases.llvm.org/3.4.2/cfe-3.4.2.src.tar.gz -o clang.tar.gz
curl http://releases.llvm.org/3.4/clang-tools-extra-3.4.src.tar.gz -o extra.tar.gz
curl http://releases.llvm.org/3.4/compiler-rt-3.4.src.tar.gz -o compiler-rt.tar.gz

解压源代码、整理文件

tar -zxvf llvm.tar.gz
tar -zxvf clang.tar.gz
tar -zxvf extra.tar.gz
tar -zxvf compiler-rt.tar.gz
mv llvm-3.4.2.src/ llvm
mv cfe-3.4.2.src/ clang
mv compiler-rt-3.4/ compiler-rt
mv clang/ llvm/tools/
mv compiler-rt llvm/projects/  

创建编译目录,并切换到build目录

mkdir build && cd build

编译

cmake -G "Unix Makefiles" ../llvm
make
make install

工具简介

clang: C语言编译器,类似于gcc
clang++: C++编译器,类似于g++。clang++只是clang的一个别名。
clang-format:按照固定的规范格式化C/C++代码,非常智能。文档请见:http://clang.llvm.org/docs/ClangFormat.html
clang-modernize:把按照C++98标准写的代码,转成C++11标准的。文档请见:http://clang.llvm.org/extra/ModernizerUsage.html
llvm-as:LLVM 汇编器
llvm-dis: LLVM 反汇编器
opt:LLVM 优化器
llc:LLVM 静态编译器
lli:LLVM的字节码执行器(某些平台下支持JIT)
llvm-link:LLVM的字节码链接器
llvm-ar:LLVM的静态库打包器,类似unix的ar。
llvm-nm:类似于unix的nm
llvm-ranlib:为 llvm-ar 打包的文件创建索引
llvm-prof:将 ‘llvmprof.out’ raw 数据格式化成人类可读的报告
llvm-ld :带有可装载的运行时优化支持的通用目标连接器
llvm-config:打印出配置时 LLVM 编译选项、库、等等
llvmc:一个通用的可定制的编译器驱动
llvm-diff:比较两个模块的结构
bugpoint:自动案例测试减速器
llvm-extract:从 LLVM 字节代码文件中解压出一个函数
llvm-bcanalyzer:字节代码分析器 (分析二进制编码本身,而不是它代表的程序)
FileCheck:灵活的文件验证器,广泛的被测试工具利用
tblgen:目标描述阅读器和生成器
lit:LLVM 集成测试器,用于运行测试

参考:

  1. http://www.runoob.com/nodejs/nodejs-npm.html
  2. http://www.shayanderson.com/linux/install-python-3-on-centos-6-server.htm
  3. http://llvm.org/docs/GettingStarted.html#checkout
  4. http://llvm.org/docs/GettingStarted.html#getting-started-quickly-a-summary
  5. http://blog.csdn.net/c_sdnq2451q/article/details/46999119
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值