centos安装 nodejs

1.包管理安装

百度一堆乱七八糟的教程,加上node各种版本,其实官方稳定就有包管理的安装方法,几条命令就可以安装好各种版本。
官方文档地址:https://nodejs.org/en/download/package-manager/

Run as root on RHEL,CentOS or Fedora,for Node.js v4 LTS Argon:

curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -

Alternatively for Node.js v6:

curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

Alternatively for Node.js 0.10:

curl --silent --location https://rpm.nodesource.com/setup | bash -

Then install,as root:
yum -y install nodejs

就这样,不能再简单。

2.源码安装

来自官方文档(会看官方文档多重要)
https://github.com/nodejs/node/wiki/Installation

准备命令:
yum -y install gcc make gcc-c++ openssl-devel wget

下面是安装版本0.12.7,安装其他版本只需要替换掉就行,所有版本地址:https://nodejs.org/dist/

ver=0.12.7 #Replace this with the latest version available
wget -c https://nodejs.org/dist/v$ver/node-v$ver.tar.gz #This is to download the source code.
tar -xzf node-v$ver.tar.gz
cd node-v$ver
./configure && make && sudo make install

验证是否安装配置成功:

node -v

相关文章

linux下开机自启: 在/etc/init.d目录下新建文件elasticsear...
1、因为在centos7中/etc/rc.d/rc.local的权限被降低了,所以...
最简单的查看方法可以使用ls -ll、ls-lh命令进行查看,当使用...
ASP.NET Core应用程序发布linux在shell中运行是正常的。可一...
设置时区(CentOS 7) 先执行命令timedatectl status|grep &...
vim /etc/sysconfig/network-scripts/ifcfg-eth0 B...