环境:

系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡)

系统版本:CentOS-7.0-1406-x86_64-DVD.iso

安装步骤:

1.准备

1.1 显示系统版本
[root@centos ~]# cat /etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

[root@centos ~]# uname -r

3.10.0-514.6.1.el7.x86_64

1.2 安装基本软件包

[root@centos ~]# yum install vim wget lsof gcc gcc-c++ -y

1.3 显示IP地址

[root@centos ~]# ip addr|grep inet

inet 127.0.0.1/8 scope host lo
inet 192.168.1.10/24 brd 192.168.1.255 scope global ens160

2.安装nodejs

2.1 安装依赖
[root@centos ~]# yum install openssl-devel -y

2.2 安装nodejs

[root@centos ~]# cd /usr/local/src/

[root@centos ~]# wget https://nodejs.org/dist/v6.9.5/node-v6.9.5.tar.gz

[root@centos ~]# tar -zxvf node-v6.9.5.tar.gz

[root@centos ~]# cd node-v6.9.5

[root@centos ~]# ./configure --prefix=/opt/node/6.9.5

[root@centos ~]# make && make install

添加软连接,否则服务没法启动

[root@centos ~]# ln -s /opt/node/6.9.5/bin/node /usr/local/bin/node

2.3 配置NODE_HOME 进入profile编辑环境变量

[root@centos ~]# vim /etc/profile

找到export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

在这行上面添加以下内容

#SET FOR NODEJS
export NODE_HOME=/opt/node/6.9.5
export PATH=$NODE_HOME/bin:$PATH

保存,退出

[root@centos ~]# source /etc/profile

[root@centos ~]# node -v

[root@centos ~]# npm -v

输出node npm 的版本号则表示配置成功

2.4 创建www需要的目录、配置用户和用户组

[root@centos ~]# groupadd www

[root@centos ~]# useradd -g www www -s /sbin/nologin

[root@centos ~]# mkdir -p /data/www

[root@centos ~]# chown -R www:www /data/www

2.5 建立基于 express 测试网站

[root@centos ~]# npm install express -gd

[root@centos ~]# npm install express-generator -g

[root@centos ~]# cd /data/www

[root@centos ~]# express -e start

[root@centos ~]# cd start && npm install

2.6 建立启动服务

[root@centos ~]# npm install forever -gd

[root@centos ~]# forever list

显示No forever processes running则表示安装成功

[root@centos ~]# forever start -a /data/www/start/bin/www

[root@centos ~]# forever stop -a /data/www/start/bin/www

[root@centos ~]# vim /lib/systemd/system/node.service

添加以下内容

[Unit]
Description=nodejs
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile==/run/node.pid
ExecStart=/opt/node/6.9.5/bin/forever start -a /data/www/start/bin/www
ExecReload=/opt/node/6.9.5/bin/forever restart -a /data/www/start/bin/www
ExecStop=/opt/node/6.9.5/bin/forever stop /data/www/start/bin/www
PrivateTmp=true

[Install]
WantedBy=multi-user.target

保存,退出

[root@centos ~]# systemctl enable node.service

[root@centos ~]# systemctl list-unit-files|grep enabled|grep node

2.7 启动服务
[root@centos ~]# systemctl daemon-reload

[root@centos ~]# systemctl start node.service

[root@centos ~]# systemctl status node.service -l

[root@centos ~]# ps -ef|grep node

2.8 防火墙添加3000端口

[root@centos ~]# iptables -L|grep ACCEPT

[root@centos ~]# firewall-cmd --zone=public --add-port=3000/tcp --permanent

[root@centos ~]# firewall-cmd --reload

[root@centos ~]# iptables -L|grep ACCEPT

2.9 浏览器打开

http://192.168.1.10:3000

显示出欢迎内容,则表示成功

CentOS 编译安装 Nodejs (实测 笔记 Centos 7.3 + node 6.9.5)的更多相关文章

  1. CentOS7 编译安装 Nodejs (实测 笔记 Centos 7.0 + node 0.10.33)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  2. CentOS 编译安装 Redis (实测 笔记 Centos 7.3 + redis 3.2.8)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  3. CentOS7 编译安装 Mongodb (实测 笔记 Centos 7.0 + Mongodb 2.6.6)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  4. CentOS7 编译安装 Nginx (实测 笔记 Centos 7.0 + nginx 1.6.2)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  5. CentOS7 编译安装 Mariadb (实测 笔记 Centos 7.0 + Mariadb 10.0.15)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  6. CentOS编译安装NodeJS+Express

    NodeJS是基于Chrome’s Javascript runtime,也就是Google V8引擎执行Javascript的快速构建网络服务及应用的平台,其优点有: 在CentOS编译安装Node ...

  7. CentOS编译安装nodejs

    1. 从node.js官网下载最新版的node.js安装包,node.tar.gz wget https://nodejs.org/dist/v4.3.1/node-v4.3.1.tar.gz    ...

  8. Centos 编译安装nodejs&express框架

    一. 下载nodejs 版本 wget http://nodejs.org/dist/v0.10.28/node-v0.10.28.tar.gz 二. 编译安装 cp node-v0.10.28.ta ...

  9. Centos编译安装PHP 5.5笔记

    本篇是在 Centos 6.4 32bit 下编译安装 php 5.5.5 的笔记,接上篇 Centos编译安装Apache 2.4.6笔记.php 5.5.x 和 centos 源里面的 php 5 ...

随机推荐

  1. C#创建控制台项目引用Topshelf的方式,部署windows服务。

    上一篇是直接创建windows service服务来处理需求.调试可能会麻烦一点.把里面的逻辑写好了.然后受大神指点,用Topshelf会更好一些. 来公司面试的时候问我,为什么要用stringbui ...

  2. hihocoder 1176

    hihocoder 1176 题意:N,M.分别表示岛屿数量和木桥数量,一笔画 分析:欧拉路问题(给定无孤立结点图G,若存在一条路,经过图中每边一次且仅一次,该条路称为欧拉路) 欧拉路的条件 一个无向 ...

  3. 微信中音乐播放在ios不能自动播放解决

    在微信中,ios手机下面音乐被自动禁掉无法自动播放,我们可以执行触发body上的元素,自动进行播放. //音乐 var x = document.getElementById("myAudi ...

  4. nginx 配置proxy_pass URL末尾加与不加/(斜线)的区别

    nginx在配置proxy_pass的时候 URL结尾加斜线(/)与不加的区别和注意事项 假设访问路径的 /pss/bill.html 加/斜线的情况 location /pss/ { proxy_p ...

  5. MVC 前端页面ViewData参数名不区分大小写

    项目中实际应用: 后台赋值时传的是:ViewData["CheckedSystemMenu"], 前台取值时:ViewData["checkedsystemmenu&qu ...

  6. [MySQL]如何支持utf8格式的UCS4unicode字符

    filed中必须是CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci: 连接时必须set names "utf8mb4": 这是一段P ...

  7. Idea 使用小技巧【取消自动打开项目】

    受到我沈誉大大的启发,把每次的项目自动启动上次的项目给关掉,其实不管掉也行,既然这样,那还是关掉吧. ctrl + alt + s 输入 system Settings 然后把Reopen last ...

  8. js数据结构与算法——二叉树

    function BinaryTree(){ var Node = function(key){ this.key = key; //值 this.left = null; //左箭头 this.ri ...

  9. 高可用Redis(九):Redis Sentinel

    1.主从复制高可用的问题 主从复制高可用的作用 1.为master提供备份,当master宕机时,slave有完整的备份数据 2.对master实现分流,实现读写分离 但是主从架构有一个问题 1.如果 ...

  10. ffmypeg 视频处理类库使用方法

    (经常用到ffmpeg 做一些视频数据的处理转换等,用来做测试,今天总结了一下,参考了网上部分朋友的经验,一起在这里汇总了一下,有需要的朋友可以收藏测试一下,有问题欢迎在下面回帖交流,谢谢;by te ...