如何部署yeoman angular-fullstack项目?

tof*_*ffd 12 nginx node.js angularjs yeoman yo

我想部署一个简单的角度projet,使用角度fullstack.

https://github.com/DaftMonk/generator-angular-fullstack

我试过了 :

yo angular-fullstack test

grunt build
Run Code Online (Sandbox Code Playgroud)

然后,在dist我有2个文件夹:server和public.

如何在Linux服务器上部署它们?

与forever/node和nginx ??? 我想自己主持我的项目.

谢谢

mes*_*lds 14

1.)安装nginx

2.)将代理转发nginx到您的节点端口.请参阅Digital Oceans How-To.

nginx.conf

 server {
    listen       80;
    server_name  localhost;

    location / {
                 proxy_pass http://localhost:9000;
                 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;
    }
}
Run Code Online (Sandbox Code Playgroud)

3.)使用正确的变量启动带有dist文件夹中节点的app.js:

$ export NODE_ENV=production; export PORT=9000; node dist/server/app.js
Run Code Online (Sandbox Code Playgroud)

4.)浏览到步骤2中在nginx中配置的主机名.

如果你得到很多404,你最有可能在HTML5模式下使用angular.js并需要重新连线你的路线以提供静态angular.js内容.我描述了这个以及如何解决您在我的博客文章中可能遇到的许多其他错误:" 与Angular Fullstack的持续集成 ".


yog*_*ogs 6

您也可以尝试使用pm2,它简单易用,具有许多实用功能.

https://github.com/Unitech/pm2

// Start new node process
$ pm2 start dist/server/app.js

// list all process
$ pm2 list
Run Code Online (Sandbox Code Playgroud)