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 ...
随机推荐
- C++内存管理
1. 栈(Stack): 位于函数内的局部变量(包括函数实参),由编译器负责分配释放,函数结束,栈变量失效.2. 堆(Heap): 由new申请的内存,由delete负责 ...
- FileUtil(from logparser)
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; ...
- MySQL存储过程动态SQL语句的生成
用Mysql存储过程来完成动态SQL语句,使用存储过程有很好的执行效率: 现在有要求如下:根据输入的年份.国家.节假日类型查询一个节假日,我们可以使用一般的SQL语句嵌入到Java代码中,但是执行效率 ...
- Delphi中DBChart的数据库应用
一:属性相关:Series选项: (1)Format页(数据柱的风格) 在Color Each中打勾,就可使用多种颜色显示,color按钮用于设置颜色,Style用于设置图表的风格(Rectangle ...
- 定位以及z-index
定位 定位用来控制元素的位置 定位的关键字是position,position有4个值,分别是relative,absolute,static,fixed当元素定位以后,元素有4个值可以用,分别是le ...
- Web应用性能优化思路
瓶颈是什么? 一条4车道的公路,运行非常顺畅,突然出了点事故,事故车导致某个地方只剩下1车道,然后就开始堵车,因为四辆车同时塞向一个车道里.把这个事故清除了,故障车拖走了,道路会开始恢复了通畅. 这个 ...
- MFC 按钮如何改变颜色
我们发现想改变对话框的背景颜色是很简单的,但是对话框的背景颜色改变了后,我们发现按钮的颜色没有改变,如下图. 这样做出来的对话框看起来,不是很自然,我们也想把按钮的颜色改变一下.这就用到了按钮的重绘. ...
- android studio使用部分报错处理
1.android studio 导入项目时Error:SSL peer shut down incorrectly 今天导入一个项目到studio,显示在下载一个一个1.1.0-rc4的东西. 过了 ...
- laravel5笔记
数据库表创建E:\PHP\learnlaravel5>php artisan migrate 创建modelE:\PHP\learnlaravel5>php artisan make:mo ...
- 【leetcode】Remove Nth Node From End of List
题目简述: Given a linked list, remove the nth node from the end of list and return its head. For example ...