日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > centos >内容正文

centos

CentOS 编译安装 Nodejs (实测 笔记 Centos 7.3 + node 6.9.5)

發(fā)布時(shí)間:2024/7/5 centos 87 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CentOS 编译安装 Nodejs (实测 笔记 Centos 7.3 + node 6.9.5) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

環(huán)境:

系統(tǒng)硬件:vmware vsphere (CPU:2*4核,內(nèi)存2G,雙網(wǎng)卡)

系統(tǒng)版本:CentOS-7.0-1406-x86_64-DVD.iso


安裝步驟:

1.準(zhǔn)備

1.1 顯示系統(tǒng)版本
[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 安裝依賴(lài)
[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

添加軟連接,否則服務(wù)沒(méi)法啟動(dòng)

[root@centos ~]# ln -s /opt/node/6.9.5/bin/node /usr/local/bin/node


2.3 配置NODE_HOME 進(jìn)入profile編輯環(huán)境變量

[root@centos ~]# vim /etc/profile

找到export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

在這行上面添加以下內(nèi)容

#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 的版本號(hào)則表示配置成功


2.4 創(chuàng)建www需要的目錄、配置用戶(hù)和用戶(hù)組

[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 測(cè)試網(wǎng)站

[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 建立啟動(dòng)服務(wù)

[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

添加以下內(nèi)容

[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 啟動(dòng)服務(wù)?
[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 瀏覽器打開(kāi)

http://192.168.1.10:3000

顯示出歡迎內(nèi)容,則表示成功

轉(zhuǎn)載于:https://www.cnblogs.com/lixinhuan/p/11191786.html

總結(jié)

以上是生活随笔為你收集整理的CentOS 编译安装 Nodejs (实测 笔记 Centos 7.3 + node 6.9.5)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。