【发布时间】:2017-07-13 21:54:55
【问题描述】:
我想在 Ubuntu EC2 实例上运行一个基本的 Angular 2 应用程序。 就我而言,我安装了 Angular CLI,并在 /var/www
中创建了一个新站点ng new test
然后
ng serve --port 8080
看起来我的基本 Angular2 应用运行良好
** NG Live Development Server is listening on localhost:8080, open your browser on http://localhost:8080 **
Hash: e0094cf33de0e6b8f264
Time: 9090ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 171 kB {4} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.js.map (main) 5.28 kB {3} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered]
chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.18 MB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
我知道我的安全组中的 8080 端口是开放的,因为我刚刚几分钟前在 /var/www 中运行了一个基本的 Node JS 应用程序。当我尝试访问http://[Public DNS]:8080 时,Safari 说它无法连接。我的 apache 日志中也没有任何内容。
【问题讨论】:
-
我建议
ng building 站点并静态部署生成的文件 -ng serve是开发服务器,不适合生产使用。 -
以@jonrsharpe 所说的为基础,relevant issue 关于不推荐
ng serve用于生产用途。还有deployment documentation for Angular -
我有点想知道为什么我的示例 CLI 应用程序不起作用,因为看起来我正在密切遵循这里的说明(至少就让 Angular 工作而言)。scotch.io/tutorials/deploying-a-mean-app-to-amazon-ec2-part-1
-
我的意思是,我知道我应该使用比普通服务器更强大的东西。但似乎开发服务器应该可以工作了。
-
你试过 ng serve --host 0.0.0.0 --port 8080 吗?
标签: node.js angular amazon-web-services amazon-ec2