how to deploy yeoman angular-fullstack project?

不问归期 提交于 2020-01-11 15:31:11

问题


I want to deploy a simple angular projet made with angular fullstack.

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

I tried :

yo angular-fullstack test

grunt build

Then, in dist I got 2 folders: server and public.

how to deploy them on a linux server ?

with forever/node and nginx ??? I want to self host my project.

thanks


回答1:


1.) Install nginx

2.) Proxy forward nginx to your node port. See 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;
    }
}

3.) Start app.js with node in your dist folder with the correct variables:

$ export NODE_ENV=production; export PORT=9000; node dist/server/app.js

4.) Browse to the hostname configured in nginx in step 2.

In case you get many 404's you most likely are using angular.js in HTML5 mode and need to re-wire your routes to serve static angular.js content. I described this and how-to tackle many other bugs that you may face in my blog article: "Continous Integration with Angular Fullstack".




回答2:


You can try pm2 as well which is straightforward and easy, it comes with lots of useful features.

https://github.com/Unitech/pm2

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

// list all process
$ pm2 list



回答3:


Also, if you're running a mongo db with a host you will need to change the /server/config/environment/production.js uri to match development.js and it should work.

With MongoLab you have something to this effect: mongodb://user:pass@XXXXX.mongolab.com:XXXXX/yourdatabase

then run the grunt serve:dist command in your app directory.

This worked for me.




回答4:


Install generator-angular-fullstack:

npm install -g generator-angular-fullstack

Make a new directory, and cd into it:

mkdir my-new-project && cd $_

Run yo angular-fullstack, optionally passing an app name:

yo angular-fullstack [app-name]

Run grunt for building, gruntserve for preview, andgrunt serve:dist` for a preview of the built app



来源:https://stackoverflow.com/questions/28751792/how-to-deploy-yeoman-angular-fullstack-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!