uname -a cat /proc/version
1.cat /etc/redhat-release(此方法只适合Redhat 系的Linux) 2.lsb_release -a (此命令适用于所有的Linux 发行版本)
cd /home/appmanager/nodejs/
wget -c https://npm.taobao.org/mirrors/node/v16.9.1/node-v16.9.1-linux-x64.tar.xz
tar -xvf node-v16.9.1-linux-x64.tar.xz mv node-v16.9.1-linux-x64 nodejs
ln -s /home/appmanager/nodejs/nodejs/bin/npm /usr/local/bin/ ln -s /home/appmanager/nodejs/nodejs/bin/node /usr/local/bin/ node -v
var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, { 'Content-Type': 'text/plain' }); response.end('Hello World\n'); }).listen(8090); console.log('Server running at http://127.0.0.1:8090/');
npm install pm2 -g ln -s /home/appmanager/nodejs/nodejs/bin/pm2 /usr/local/bin/
pm2 start app.js -e err.log -o out.log
var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});//只需要设置响应头的编码格式就好,解决中文乱码问题的代码 // response.writeHead(200, { 'Content-Type': 'text/plain' }); // 原有代码 response.end('Hello World--测试\n'); }).listen(8090); console.log('Server running at http://127.0.0.1:8090/');
pm2 restart app
pm2 list
pm2 stop #id
pm2 restart #id
pm2 stop all
pm2 start all
pm2 delete #id
pm2 delete all
pm2 start app.js //启动js文件 pm2 start echo.php //启动php文件 pm2 start echo.py //启动py文件 pm2 start echo.sh //启动sh文件 pm2 start echo.rb //启动ruby文件 pm2 start app.json //启动json文件 pm2 start ./binary-app //启动二进制代码