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 ...
随机推荐
- Percona XtraBackup 备份原理说明【转】
本文来自:http://mysql.taobao.org/monthly/2016/03/07/ 前言 Percona XtraBackup(简称PXB)是 Percona 公司开发的一个用于 MyS ...
- mmap为什么比read/write快(兼论buffercache和pagecache)
参考文献: <从内核文件系统看文件读写过程>http://www.cnblogs.com/huxiao-tee/p/4660352.html?utm_source=tuicool& ...
- php阳历转农历的类 谷歌到的
<?phpclass Lunar { var $MIN_YEAR = 1891; var $MAX_YEAR = 2100; var $lunarInfo = array( ...
- <%@ page trimDirectiveWhitespaces="true" %>
我们经常会在JSP页面上使用: <%@ page trimDirectiveWhitespaces="true" %> 这个命令可以使jsp输出的html时去除多余的空 ...
- LeetCode 290 Word Pattern
Problem: Given a pattern and a string str, find if str follows the same pattern. Here follow means a ...
- 【WEB】web www http html hypermedia hypertext 技术名词的意思
www WWW是环球信息网的缩写,(亦作"Web"."WWW"."'W3'",英文全称为"World Wide Web" ...
- JS截取,删除,替换字符串常用方法详细
删除和替换是一样的,开始用的是,如果是删除就直接替换为空 arr="abc001abc002abc003" arr.replace('abc','123') 结果发现只能替换第一个 ...
- tp框架实现ajax
不墨迹,直接进主题. tp框架实现ajax 首先,我们先做一个testajax.html用来显示页面(只是一个简单的下拉列表^_^) <!DOCTYPE html PUBLIC "-/ ...
- freemarker 中文乱码
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker ...
- CentOS7 学习笔记
1.首先centos7 采用了systemd管理系统服务的启动 systemd结合了以前红帽子的service 与chkconfig systemctl [command] [unit] comm ...