我想部署一个用 Angular 全栈制作的简单 Angular 项目。
https://github.com/DaftMonk/generator-angular-fullstack https://github.com/DaftMonk/generator-angular-fullstack
我试过 :
yo angular-fullstack test
grunt build
然后,在 dist 中我得到了 2 个文件夹:server 和 public。
如何将它们部署在Linux服务器上?
与forever/node 和nginx ???
我想自行托管我的项目。
thanks
1.) 安装nginx
2.) 代理转发nginx到您的节点端口。看数字海洋操作指南 https://www.digitalocean.com/community/tutorials/how-to-host-multiple-node-js-applications-on-a-single-vps-with-nginx-forever-and-crontab.
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.) 启动app.js在 dist 文件夹中使用节点并使用正确的变量:
$ export NODE_ENV=production; export PORT=9000; node dist/server/app.js
4.) 浏览到主机名在第 2 步中在 nginx 中配置。
万一你得到很多404您最有可能正在使用HTML5 模式下的 angular.js并且需要重新连接您的路由以提供静态 angular.js 内容。我在我的博客文章中描述了这一点以及如何解决您可能遇到的许多其他错误:“与 Angular 全栈持续集成 http://meshfields.de/continuous-integration-angular-fullstack/".
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)