且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Angular 5为AWS EC2创建应用程序源捆绑包

更新时间:2023-11-22 17:53:40

我上面问题中的主要罪魁祸首是试图通过以下方式在AWS中运行Angular 5应用程序:使用他们选择的node.js作为我的服务器平台。这是我学到的(在 Albert Haff 等人的帮助下:Angular 5使用Node(ngserve)来在编写代码时模拟网络服务器,但是,即使--prod有受支持的标志,也不用在生产中!部署Angular 5应用程序时,很容易(很诱人)选择node.js作为环境通过Beanstalk-但不要这样做!

The cardinal sin in my question above was attempting to run my Angular 5 app in AWS by using their choice for node.js as my server platform. Here is what I learned (with some help from folks like Albert Haff: Angular 5 uses Node (ng serve) to simulate a webserver while you code. However, even though there is a supported flag for --prod, it's not to be used in production! It's really easy (and tempting) to select node.js as the environment when deploying your Angular 5 app via Beanstalk -- but don't do it!


  1. 从Angular 5项目文件夹中,运行ng build --prod(并考虑如果可以的话,添加--aot)

  2. 如果可以的话,可以在构建刚刚创建(或更新)的新/ dist文件夹中,为我在中运行压缩dist / *;执行brotli $ i;完成

  3. ,从/ dist文件夹中压缩所有内容,包括子文件夹。

  4. 转到beantalk,然后在创建Web服务器环境时,选择Tomcat(或其他任何普通的旧Web服务器,但是不要选择node.js,即使它位于列表!)。

  5. 在应用程序代码上,选择上传自己的文件,然后浏览到在上面的第3步中创建的.zip文件。

  6. 单击创建环境,几分钟后您的Angular 5应用将可以在互联网上运行。

  1. from within your Angular 5 project folder, run ng build --prod ( and consider adding --aot)
  2. if you can, from within the new /dist folder that the build just created (or updated), optionally run compression like for i in dist/*; do brotli $i; done
  3. from within the /dist folder, zip up ALL the contents including subfolders.
  4. go to beanstalk, and as you create a webserver environment, select Tomcat (or any other plain old webserver, but DON'T pick node.js even though it's on the list!).
  5. on Application Code, select to Upload Your Own, and browse to the .zip file you created in step 3 above.
  6. click Create Environment and in a few minutes your Angular 5 app will be serving up on the internet.

现在,从这里开始需要连接您的域名。为此,请使用Route 53。

Now, from here you will likely need to connect up your domain name. Use Route 53 for that.