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 显示系统版本
[root@centos ~]# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)
[root@centos ~]# uname -a
Linux tCentos7 3.10.0-123.9.3.el7.x86_64 #1 SMP Thu Nov 6 15:06:03 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
1.2 安装基本软件包
[root@centos ~]# yum install vim wget lsof gcc gcc-c++ -y
[root@centos ~]# yum install net-tools bind-utils -y
1.3 显示IP地址 (centos7需要先安装 net-tools bind-utils包)
[root@centos ~]# ifconfig|grep inet
inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
2.安装nodejs
2.1 安装依赖
[root@centos ~]# yum install openssl-devel -y
2.2 安装nodejs
[root@centos ~]# cd /usr/local/src/
[root@centos ~]# wget http://nodejs.org/dist/v0.10.33/node-v0.10.33.tar.gz
[root@centos ~]# tar -zxvf node-v0.10.33.tar.gz
[root@centos ~]# cd node-v0.10.33
[root@centos ~]# ./configure --prefix=/opt/node/0.10.33
[root@centos ~]# make && make install
添加软连接,否则服务没法启动
[root@centos ~]# ln -s /opt/node/0.10.33/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/0.10.33
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/0.10.33/bin/forever start -a /data/www/start/bin/www
ExecReload=/opt/node/0.10.33/bin/forever restart -a /data/www/start/bin/www
ExecStop=/opt/node/0.10.33/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
显示出欢迎内容,则表示成功
CentOS7 编译安装 Nodejs (实测 笔记 Centos 7.0 + node 0.10.33)的更多相关文章
- CentOS 编译安装 Nodejs (实测 笔记 Centos 7.3 + node 6.9.5)
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...
- 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 显示系统版 ...
- 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 显示系统版 ...
- 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 显示系统版 ...
- 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 显示系统版 ...
- CentOS7编译安装NodeJS
概述 在CentOS7下采用编译NodeJS二进制源码包的方式安装NodeJS 下载NodeJS安装包 你可以先下载NodeJS二进制源码安装包文件然后上传到CentOS系统,也可以通过wget命令直 ...
- CentOS7 编译安装nodejs,配置环境变量记录
每次都装,每次都查 阿里云备案了一个域名,续费了好多年,但是没钱买服务器,就挂在github上.今天收到消息:域名解析服务器不在阿里云,要被GG.只能咬牙买了个阿里云乞丐版. 所有服务都装好了,pin ...
- CentOS编译安装nodejs
1. 从node.js官网下载最新版的node.js安装包,node.tar.gz wget https://nodejs.org/dist/v4.3.1/node-v4.3.1.tar.gz ...
- CentOS编译安装NodeJS+Express
NodeJS是基于Chrome’s Javascript runtime,也就是Google V8引擎执行Javascript的快速构建网络服务及应用的平台,其优点有: 在CentOS编译安装Node ...
随机推荐
- SDWebImage清理图片缓存方法
//获取当前缓存大小 @property (nonatomic, assign) NSUInteger tmpSize; //获取缓存大小并储存 _tmpSize=[[SDImageCache sha ...
- linux下用c实现ls命令
struct dirent中的几个成员: d_type:4表示为目录,8表示为文件 d_reclen:16表示子目录或文件,24表示非子目录 d_name:目录或文件的名称 #include < ...
- Flex中的initialize,creationComplete和applicationComp
转自:http://blog.csdn.net/sjz168/article/details/7244374 1.Application标签中有三个事件initialize,creationCompl ...
- gulp整理
gulp基于node 1.全局安装gulp: $ npm install --global gulp 2.前往项目目录,然后安装作为项目的开发依赖(devDependencies): $ npm in ...
- 使用Slf4j集成Log4j2构建项目日志系统的完美解决方案
一.背景 最近因为公司项目性能需要,我们考虑把以前基于的log4j的日志系统重构成基于Slf4j和log4j2的日志系统,因为,使用slf4j可以很好的保证我们的日志系统具有良好的兼容性,兼容当前常见 ...
- 使用Word 2013发布cnblogs随笔
博客园支持Word或者OneNote一键发布文章. 获取cnblogs的URL地址,类似http://rpc.cnblogs.com/metaweblog/your_name 打开word中的管理账户 ...
- 【leetcode】ZigZag Conversion
题目简述 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows ...
- CozyRSS开发记录10-RSS源管理
CozyRSS开发记录10-RSS源管理 1.RSS源树结构 做解析体力活很多,把RSS解析的优化先放放,先玩一玩RSS源的管理. 虽然在初步的设计中,RSS源是以一个列表的方式来展示,但是,我觉得如 ...
- Stack Overflow: The Architecture - 2016 Edition(Translation)
原文: https://nickcraver.com/blog/2016/02/17/stack-overflow-the-architecture-2016-edition/ 作者:Nick Cra ...
- hellocharts折线图与柱状图的上下结合酷炫效果(学习笔记)
二话不说先贴图 贴代码: LineColumnDependencyActivity.java package com.shaoxin.mylinecolumndependencyactivity; i ...