How to install and configure node js and PM2 in rhel7
OS RHEL7.6 Minimal Install
Download : libuv-1.7.5-3.el7.x86_64.rpm , nodejs-4.7.2-1.el7.x86_64.rpm
[root@node1 ~]# rpm -ivh nodejs-4.7.2-1.el7.x86_64.rpm
warning: nodejs-4.7.2-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
libuv >= 1:1.7.5 is needed by nodejs-4.7.2-1.el7.x86_64
libuv.so.1()(64bit) is needed by nodejs-4.7.2-1.el7.x86_64
[root@node1 ~]# rpm -ivh libuv-1.7.5-3.el7.x86_64.rpm
warning: libuv-1.7.5-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:libuv-1:1.7.5-3.el7 ################################# [100%]
[root@node1 ~]# rpm -ivh nodejs-4.7.2-1.el7.x86_64.rpm
warning: nodejs-4.7.2-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:nodejs-4.7.2-1.el7 ################################# [100%]
You can verify if Node.js is installed by checking its version:
[root@node1 ~]# node -v
v4.7.2
[root@node1 ~]# npm -v
2.15.11
Use Node.js Packaged Modules (NPM) to install PM2 on our app server. Npm is a package manager for installing Node.js modules.
[root@node1 ~]# npm install pm2 -g
npm WARN optional dep failed, continuing fsevents@1.2.7
npm WARN engine proxy-agent@3.0.3: wanted: {"node":">=6"} (current: {"node":"4.7.2","npm":"2.15.11"})
npm WARN engine socks-proxy-agent@4.0.1: wanted: {"node":">= 6"} (current: {"node":"4.7.2","npm":"2.15.11"})
npm WARN engine socks@2.2.3: wanted: {"node":">= 6.0.0","npm":">= 3.0.0"} (current: {"node":"4.7.2","npm":"2.15.11"})
npm WARN engine readable-stream@3.1.1: wanted: {"node":">= 6"} (current: {"node":"4.7.2","npm":"2.15.11"})
npm WARN engine smart-buffer@4.0.2: wanted: {"node":">= 4.0.0","npm":">= 3.0.0"} (current: {"node":"4.7.2","npm":"2.15.11"})
/usr/bin/pm2 -> /usr/lib/node_modules/pm2/bin/pm2
/usr/bin/pm2-dev -> /usr/lib/node_modules/pm2/bin/pm2-dev
/usr/bin/pm2-docker -> /usr/lib/node_modules/pm2/bin/pm2-docker
/usr/bin/pm2-runtime -> /usr/lib/node_modules/pm2/bin/pm2-runtime
pm2@3.3.1 /usr/lib/node_modules/pm2
├── gkt@1.0.0
├── v8-compile-cache@2.0.2
├── commander@2.15.1
├── eventemitter2@5.0.1
├── semver@5.6.0
├── pm2-axon-rpc@0.5.1
├── fclone@1.0.11
├── sprintf-js@1.1.1
├── debug@3.2.6 (ms@2.1.1)
├── pidusage@2.0.17 (safe-buffer@5.1.2)
├── pm2-deploy@0.4.0 (tv4@1.3.0)
├── pm2-multimeter@0.1.2 (charm@0.1.2)
├── promptly@2.2.0 (read@1.0.7)
├── pm2-axon@3.3.0 (amp-message@0.1.2, escape-regexp@0.0.1, amp@0.3.1)
├── mkdirp@0.5.1 (minimist@0.0.8)
├── source-map-support@0.5.10 (buffer-from@1.1.1, source-map@0.6.1)
├── nssocket@0.6.0 (eventemitter2@0.4.14, lazy@1.0.11)
├── cli-table-redemption@1.0.1 (chalk@1.1.3)
├── chalk@2.4.2 (escape-string-regexp@1.0.5, supports-color@5.5.0, ansi-styles@3.2.1)
├── @pm2/agent@0.5.23 (ws@5.2.2)
├── blessed@0.1.81
├── cron@1.6.0 (moment-timezone@0.5.23)
├── needle@2.2.4 (sax@1.2.4, debug@2.6.9, iconv-lite@0.4.24)
├── yamljs@0.3.0 (glob@7.1.3, argparse@1.0.10)
├── @pm2/js-api@0.5.49 (eventemitter2@4.1.2, debug@2.6.9, ws@3.3.3, axios@0.16.2)
├── chokidar@2.1.2 (normalize-path@3.0.0, path-is-absolute@1.0.1, async-each@1.0.1, inherits@2.0.3, upath@1.1.0, is-glob@4.0.0, is-binary-path@1.0.1, glob-parent@3.1.0, braces@2.3.2, readdirp@2.2.1, anymatch@2.0.0)
├── shelljs@0.8.3 (interpret@1.2.0, glob@7.1.3, rechoir@0.6.2)
├── moment@2.24.0
├── @pm2/io@3.1.1 (event-loop-inspector@1.2.2, signal-exit@3.0.2, semver@5.5.0, shimmer@1.2.1, tslib@1.9.3, debug@3.1.0, @pm2/legacy-tracing@1.4.2, @pm2/agent-node@1.1.6)
├── vizion@2.0.2 (lodash.foreach@4.5.0, ini@1.3.5, lodash.last@3.0.0, lodash.get@4.4.2, lodash.findindex@4.6.0, git-node-fs@1.0.0, js-git@0.7.8, async@2.6.1)
├── date-fns@1.30.1
└── async@2.6.2 (lodash@4.17.11)
Create and edit your Node.js application. In our example, we will edit a sample application called hello.js.
[root@node1 ~]# vim hello.js
var http = require('http');
http.createServer(function (req, res){
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8080, 'APP_SERVER_PUBLIC_IP');
console.log('Server running at http://APP_SERVER_PUBLIC_IP_ADDRESS:8080/');
Test your application on your app server:
[root@node1 ~]# node hello.js
Start the application with PM2 so that it runs in the background:
[root@node1 ~]# pm2 start hello.js
If you wish to stop an application, you can use the stop command. Make sure to specify the PM2 Id or App name.
[root@node1 ~]# pm2 stop App or ID
Restart the application. Be sure to indicate the app name or ID.
[root@node1 ~]# pm2 restart App or ID
YList the applications currently managed by PM2:
[root@node1 ~]# pm2 list
By using the info subcommand, you can find more information about a specific application.
Make sure you specify the PM2 id or App name in place of the highlighted portion:
[root@node1 ~]# pm2 info App or ID
Install NGINX:
[root@node1 ~]# vim /etc/yum.repos.d/yum.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/rhel/7/$basearch/
gpgcheck=0
enabled=1
[root@node1 ~]# yum install nginx
[root@node1 ~]# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf_ORG
[root@node1 ~]# mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/a.conf
NGINX location block after edit:
[root@node1 ~]# vim /etc/nginx/conf.d/a.conf
server {
listen 80;
server_name node1.example.com;
location / {
proxy_pass http://192.168.122.50:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Restart NGINX on your Web server:
[root@node1 ~]# service nginx restart
Download : libuv-1.7.5-3.el7.x86_64.rpm , nodejs-4.7.2-1.el7.x86_64.rpm
[root@node1 ~]# rpm -ivh nodejs-4.7.2-1.el7.x86_64.rpm
warning: nodejs-4.7.2-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
libuv >= 1:1.7.5 is needed by nodejs-4.7.2-1.el7.x86_64
libuv.so.1()(64bit) is needed by nodejs-4.7.2-1.el7.x86_64
[root@node1 ~]# rpm -ivh libuv-1.7.5-3.el7.x86_64.rpm
warning: libuv-1.7.5-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:libuv-1:1.7.5-3.el7 ################################# [100%]
[root@node1 ~]# rpm -ivh nodejs-4.7.2-1.el7.x86_64.rpm
warning: nodejs-4.7.2-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:nodejs-4.7.2-1.el7 ################################# [100%]
You can verify if Node.js is installed by checking its version:
[root@node1 ~]# node -v
v4.7.2
[root@node1 ~]# npm -v
2.15.11
Use Node.js Packaged Modules (NPM) to install PM2 on our app server. Npm is a package manager for installing Node.js modules.
[root@node1 ~]# npm install pm2 -g
npm WARN optional dep failed, continuing fsevents@1.2.7
npm WARN engine proxy-agent@3.0.3: wanted: {"node":">=6"} (current: {"node":"4.7.2","npm":"2.15.11"})
npm WARN engine socks-proxy-agent@4.0.1: wanted: {"node":">= 6"} (current: {"node":"4.7.2","npm":"2.15.11"})
npm WARN engine socks@2.2.3: wanted: {"node":">= 6.0.0","npm":">= 3.0.0"} (current: {"node":"4.7.2","npm":"2.15.11"})
npm WARN engine readable-stream@3.1.1: wanted: {"node":">= 6"} (current: {"node":"4.7.2","npm":"2.15.11"})
npm WARN engine smart-buffer@4.0.2: wanted: {"node":">= 4.0.0","npm":">= 3.0.0"} (current: {"node":"4.7.2","npm":"2.15.11"})
/usr/bin/pm2 -> /usr/lib/node_modules/pm2/bin/pm2
/usr/bin/pm2-dev -> /usr/lib/node_modules/pm2/bin/pm2-dev
/usr/bin/pm2-docker -> /usr/lib/node_modules/pm2/bin/pm2-docker
/usr/bin/pm2-runtime -> /usr/lib/node_modules/pm2/bin/pm2-runtime
pm2@3.3.1 /usr/lib/node_modules/pm2
├── gkt@1.0.0
├── v8-compile-cache@2.0.2
├── commander@2.15.1
├── eventemitter2@5.0.1
├── semver@5.6.0
├── pm2-axon-rpc@0.5.1
├── fclone@1.0.11
├── sprintf-js@1.1.1
├── debug@3.2.6 (ms@2.1.1)
├── pidusage@2.0.17 (safe-buffer@5.1.2)
├── pm2-deploy@0.4.0 (tv4@1.3.0)
├── pm2-multimeter@0.1.2 (charm@0.1.2)
├── promptly@2.2.0 (read@1.0.7)
├── pm2-axon@3.3.0 (amp-message@0.1.2, escape-regexp@0.0.1, amp@0.3.1)
├── mkdirp@0.5.1 (minimist@0.0.8)
├── source-map-support@0.5.10 (buffer-from@1.1.1, source-map@0.6.1)
├── nssocket@0.6.0 (eventemitter2@0.4.14, lazy@1.0.11)
├── cli-table-redemption@1.0.1 (chalk@1.1.3)
├── chalk@2.4.2 (escape-string-regexp@1.0.5, supports-color@5.5.0, ansi-styles@3.2.1)
├── @pm2/agent@0.5.23 (ws@5.2.2)
├── blessed@0.1.81
├── cron@1.6.0 (moment-timezone@0.5.23)
├── needle@2.2.4 (sax@1.2.4, debug@2.6.9, iconv-lite@0.4.24)
├── yamljs@0.3.0 (glob@7.1.3, argparse@1.0.10)
├── @pm2/js-api@0.5.49 (eventemitter2@4.1.2, debug@2.6.9, ws@3.3.3, axios@0.16.2)
├── chokidar@2.1.2 (normalize-path@3.0.0, path-is-absolute@1.0.1, async-each@1.0.1, inherits@2.0.3, upath@1.1.0, is-glob@4.0.0, is-binary-path@1.0.1, glob-parent@3.1.0, braces@2.3.2, readdirp@2.2.1, anymatch@2.0.0)
├── shelljs@0.8.3 (interpret@1.2.0, glob@7.1.3, rechoir@0.6.2)
├── moment@2.24.0
├── @pm2/io@3.1.1 (event-loop-inspector@1.2.2, signal-exit@3.0.2, semver@5.5.0, shimmer@1.2.1, tslib@1.9.3, debug@3.1.0, @pm2/legacy-tracing@1.4.2, @pm2/agent-node@1.1.6)
├── vizion@2.0.2 (lodash.foreach@4.5.0, ini@1.3.5, lodash.last@3.0.0, lodash.get@4.4.2, lodash.findindex@4.6.0, git-node-fs@1.0.0, js-git@0.7.8, async@2.6.1)
├── date-fns@1.30.1
└── async@2.6.2 (lodash@4.17.11)
Create and edit your Node.js application. In our example, we will edit a sample application called hello.js.
[root@node1 ~]# vim hello.js
var http = require('http');
http.createServer(function (req, res){
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8080, 'APP_SERVER_PUBLIC_IP');
console.log('Server running at http://APP_SERVER_PUBLIC_IP_ADDRESS:8080/');
Test your application on your app server:
[root@node1 ~]# node hello.js
Start the application with PM2 so that it runs in the background:
[root@node1 ~]# pm2 start hello.js
If you wish to stop an application, you can use the stop command. Make sure to specify the PM2 Id or App name.
[root@node1 ~]# pm2 stop App or ID
Restart the application. Be sure to indicate the app name or ID.
[root@node1 ~]# pm2 restart App or ID
YList the applications currently managed by PM2:
[root@node1 ~]# pm2 list
By using the info subcommand, you can find more information about a specific application.
Make sure you specify the PM2 id or App name in place of the highlighted portion:
[root@node1 ~]# pm2 info App or ID
Install NGINX:
[root@node1 ~]# vim /etc/yum.repos.d/yum.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/rhel/7/$basearch/
gpgcheck=0
enabled=1
[root@node1 ~]# yum install nginx
[root@node1 ~]# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf_ORG
[root@node1 ~]# mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/a.conf
NGINX location block after edit:
[root@node1 ~]# vim /etc/nginx/conf.d/a.conf
server {
listen 80;
server_name node1.example.com;
location / {
proxy_pass http://192.168.122.50:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Restart NGINX on your Web server:
[root@node1 ~]# service nginx restart
Thanks for sharing the valuable information.
ReplyDeleteNode JS Online training
Awesome blog.Keep on sharing this type of articles.
ReplyDeleteNode JS Online training
Node JS training in Hyderabad
Thanks for sharing the valuable blog.
ReplyDeleteFull Stack Training in Chennai | Certification | Online Training Course| Full Stack Training in Bangalore | Certification | Online Training Course | Full Stack Training in Hyderabad | Certification | Online Training Course | Full Stack Developer Training in Chennai | Mean Stack Developer Training in Chennai | Full Stack Training | Certification | Full Stack Online Training Course
perde modelleri
ReplyDeleteNumara Onay
mobil ödeme bozdurma
Nft nasıl alınır
ankara evden eve nakliyat
trafik sigortası
dedektör
WEBSİTE KURMA
AŞK KİTAPLARI
Smm Panel
ReplyDeleteSmm Panel
iş ilanları
İnstagram Takipçi Satın Al
hirdavatciburada.com
www.beyazesyateknikservisi.com.tr
SERVİS
tiktok jeton hilesi
very nice information.Thanks for post.
ReplyDeleteFull-stack training in Nagpur