Node.js 在EC2上运行Angular2应用程序

Node.js 在EC2上运行Angular2应用程序,node.js,angular,amazon-web-services,amazon-ec2,Node.js,Angular,Amazon Web Services,Amazon Ec2,我想在Ubuntu EC2实例上运行一个基本的Angular 2应用程序。 在我的例子中,我安装了Angular CLI,并在/var/www中创建了一个新站点 ng new test 然后 看起来我的基本Angular2应用程序运行良好 ** NG Live Development Server is listening on localhost:8080, open your browser on http://localhost:8080 ** Hash: e0094cf33de0e6b

我想在Ubuntu EC2实例上运行一个基本的Angular 2应用程序。 在我的例子中,我安装了Angular CLI,并在/var/www中创建了一个新站点

ng new test
然后

看起来我的基本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应用程序。当我尝试转到DNS:8080时,Safari说它无法连接。我的apache日志中也没有任何内容。

事实证明,真正的问题是:


我尝试过编辑server.js文件并使用--publicHost选项运行,但这些都不起作用。我正在使用默认端口3000的非CLI Angular,这在EC2上工作(在添加安全组设置之后)。

我建议
ng build
静态部署站点并部署生成的文件-
ng serve
是一个开发服务器,不适合生产使用。要基于@jornsharpe所说的构建,关于不推荐生产使用的
ng serve
。另外,我有点想知道为什么我的示例CLI应用程序不起作用,而看起来我是在严格遵循这里的说明(至少是在开始工作时)。我的意思是,我知道我应该使用比普通服务器更健壮的东西。但是看起来开发服务器应该可以正常工作了。您是否尝试过ng serve——主机0.0.0.0——端口8080?
** 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.