环境:

系统硬件: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#--Redis帮助类

    最近一直在忙公司的一下项目,也没有太多时间写,所以就分享出所用redis帮助类 using Newtonsoft.Json; using StackExchange.Redis; using Syst ...

  2. 谷歌的Android Q到底有哪些新特性及变更?

    Android Q 隐私更改相关介绍 存储范围变更 Android Q 改变了应用程序访问设备外部存储上文件的方式. 通过使用更细粒度的媒体特定权限替换以前的 READ_EXTERNAL_STORAG ...

  3. 对于JavaBean+Servlet+SqlServer的代码总结和打包调用

    日期:2019.3.24 博客期:049 星期日 说起来我已经说过很多次前台的应用技术了呢!这一次我是要将这一部分打包,做成配套的制作工具: 当前我已经打包成功,想要下载的同学可以进入我的GitHub ...

  4. LoadRunner学习笔记(二)

    LoadRunner Controller简介: 当虚拟用户脚本开发完成后,使用controller将这个执行脚本的用户从单用户转化为多用户,从而,模拟大量用户操作, 进而形成负债(多用户单循环,多用 ...

  5. Typescript04---模块、命名空间

    在Typescript1.5 中,内部模块称作命名空间,外部模块成为模块 一.什么是模块? 模块就是一个或一组功能模块. 模块在其自身的作用域里执行,而不是在全局作用域里.意味着,模块中的变量.函数. ...

  6. 中位数——二维坐标下的中位数lightoj1349

    第一次碰到这种题,不知所措,题解链接 => https://www.cnblogs.com/fu3638/p/7426074.html #include<bits/stdc++.h> ...

  7. Windbg分析蓝屏Dump文件

    一.WinDbg是什么?它能做什么? WinDbg是在windows平台下,强大的用户态和内核态调试工具.它能够通过dmp文件轻松的定位到问题根源,可用于分析蓝屏.程序崩溃(IE崩溃)原因,是我们日常 ...

  8. cmake简明使用指南

    cmake简明使用指南 Last update 2018/8/8 先执行cmake生成makefile,然后看看里面的内容,(至少在ubuntu16.04上的cmake3.5.1上),有如下内容提供: ...

  9. RabbitMQ 声明队列时候的参数解释

    参考链接:http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v3.6.6/rabbitmq-dotnet-client-3.6.6-cli ...

  10. 2018-2019-2 20165239 《网络对抗技术》Kali的安装 第一周

    2018-2019-<网络对抗技术> Kali安装 20165239其米仁增 一.资源下载以及工具安装 1.下载虚拟机工具VMware. 下载链接 :https://www.baidu.c ...