koa2服务器部署

一,在服务器上安装 pm2

npm install -g pm2

二,添加nginx.conf

在服务器目录创建/ect/nginx/conf.d/xxxx.conf

server {
        listen 80;
        server_name koa.dongshushu.com(换成自己的域名);
        location / {
                proxy_pass http://localhost:3000(换端口);
                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;
        }
}

重启nginx

nginx -s reload

三,开启pm2

pm2 start app

常用的pm2命令

$ pm2 list

$ pm2 stop     <app_name|id|'all'|json_conf>
$ pm2 restart  <app_name|id|'all'|json_conf>
$ pm2 delete   <app_name|id|'all'|json_conf>

pm2升级

pm2 update

评论

发表回复