centos安装nodejs并配置生产环境,基于pm2

安装nodejs和yarn的命令:

curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
//参见:https://github.com/nodesource/distributions

sudo yum install yarn

安装pm2

yarn global add pm2

配置package.json
后台静默启动的快捷命令:

"scripts": {
        "start": "pm2 start index.js --watch --name redredstar",
    },

pm2的日志文件:/root/.pm2/logs下面

查看服务器上运行的NODE服务,执行:pm2 list
删除一个服务,执行pm2 delete [appName]
 

posted @ 2019-09-17 09:42  liulun  阅读(476)  评论(0编辑  收藏  举报