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 显示系统版本
[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)的更多相关文章
- 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 显示系统版 ...
- 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 编译安装 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编译安装NodeJS+Express
NodeJS是基于Chrome’s Javascript runtime,也就是Google V8引擎执行Javascript的快速构建网络服务及应用的平台,其优点有: 在CentOS编译安装Node ...
- 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 版本 wget http://nodejs.org/dist/v0.10.28/node-v0.10.28.tar.gz 二. 编译安装 cp node-v0.10.28.ta ...
- Centos编译安装PHP 5.5笔记
本篇是在 Centos 6.4 32bit 下编译安装 php 5.5.5 的笔记,接上篇 Centos编译安装Apache 2.4.6笔记.php 5.5.x 和 centos 源里面的 php 5 ...
随机推荐
- [Kubernetes]关于 Kubernetes ,你想要的,都在这儿了
陆陆续续,关于 Kubernetes 写了有 20+ 篇文章了. 今天这篇文章来一个整合,从实践到理论,可以按需查看(我是按照博客发表时间来排序的,如果后续有想要更新的内容,也会及时更新到这篇文章中) ...
- noip2018游(AFO)记
Day 0 到学车了,已经差不多四点了,领完一小袋比赛要用的就匆匆回了宾馆. 话说之前看地图的时候我们的宾馆最远,而且名字听起来并没有怎么高大上, 一看隔壁度豪大酒店就感觉应该比我们的酒店好.然鹅到了 ...
- springboot动态多数据源
参考文章:https://www.cnblogs.com/hehehaha/p/6147096.html 前言 目标是springboot工程支持多个MySQL数据源,在代码层面上,同一个SQL(Ma ...
- mysql 经纬度求距离
SELECT id,lng,lat,ROUND(6378.138*2*ASIN(SQRT(POW(SIN((lat1*PI()/180-lat*PI()/180)/2),2)+COS(lat1*PI( ...
- Django—跨域请求(jsonp)
同源策略 如果两个页面的协议,端口(如果有指定)和域名都相同,则两个页面具有相同的源. 示例:两个Django demo demo1 url.py url(r'^demo1/',demo1), vie ...
- 第一阶段——CentOS6_Python3.6.1笔记(尚学堂-Python基础快速入门)+ 【补充】麦子-Python程序入门与进阶
虚拟机环境: 设置网络 .修改网络地址 .设置网卡为nat模式 .确保物理机启动dhcp.net服务 .编辑文件:vim /etc/sysconfig/network-scripts/ifcfg-et ...
- 怎样用css写出一个下拉菜单
<style> 2 /* css*/ 3 #body{ 4 float: left; 5 } 6 #xialakuang{ 7 background-color:#f9f9f9; 8 bo ...
- 使用With递归查询 树
UNION ALL -- 递归成员 SELECT a.* FROM tree a JOIN CTE c ON a.pid = c.id ) SELECT * from CTE --1.将 CTE ...
- P1119 灾后重建 floyd
题目背景 BB地区在地震过后,所有村庄都造成了一定的损毁,而这场地震却没对公路造成什么影响.但是在村庄重建好之前,所有与未重建完成的村庄的公路均无法通车.换句话说,只有连接着两个重建完成的村庄的公路才 ...
- java并发编程可见性与线程封闭
可见性 所谓可见性,指的是当一个线程修改了对象的状态后,其他线程能够看到该对象发生的变化.在单线程环境下,向某个变量写入值,然后在后面的操作再读取,在这个过程中该变量的值对该线程来说总是可见.但是,在 ...