如何以及如何将Angular2部署到IIS [英] How and what to deploy Angular2 to IIS

查看:744
本文介绍了如何以及如何将Angular2部署到IIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以angular2-quickstart为例。需要部署哪些文件以及需要设置哪些设置才能从IIS启动此Web应用程序?



这是我选择编译为JavaScript的Typescript教程。

解决方案

为我设置Angular 2是一个很大的问题,因为HTML5路由(没有hashbang)无效。<使用 Angular-CLI (你还需要它来构建它!):


  1. 完成项目开发后,您需要将其构建(或编译)到不同的环境中。如果您需要进行设置,请阅读

您需要的最短构建命令是:



ng b


  1. 构建文件夹中(如果您没有添加外部/不同文件夹,这将是项目中的' dist '文件夹),请将内容复制到IIS服务器。


  2. 确保IIS服务器的文件夹具有IIS_IUSRS组和IUSR用户访问它所需的权限。 (右键单击文件夹 - >属性 - >安全性 - >编辑 - >添加,然后键入。您可以单击'检查名称'按钮以确保它是您正在键入的正确的按钮


  3. 您需要解决的下一个问题是将 web.config 文件放入服务器文件夹以修复路由问题。


如果我们使用Apache,我们需要一个.htaccess,但是对于IIS ,我们正在使用web.config。如果你的这里发现了应用程序是从服务器的根目录路由。
(注意:正如@Demortes提醒的那样,这需要在IIS环境中添加一个名为 URLRewrite



此(web.config)文件位于服务器的根目录中。



希望这可以帮助任何有类似问题的人:)



干杯。


Take for instance angular2-quickstart. What files need to be deployed and what settings need to be set to launch this web app from IIS?

This is a Typescript tutorial that I have opted to compile to JavaScript.

解决方案

Setting up Angular 2 for me was quite an issue because the HTML5 routes (without a hashbang) weren't working.

To get an Angular2 project working on an IIS environment without serving it using the Angular-CLI (you still need it to build it!):

  1. After you're finished with development on your project, you'll need to build (or compile) it to a different environment. If you need to set that up, read this.

The shortest build command you need is:

ng b

  1. In your build folder (if you didn't add an external/different folder, this will be the 'dist' folder in your project), copy the contents to your IIS server.

  2. Ensure the folder of your IIS server has the needed permissions for the IIS_IUSRS group and IUSR user to access it. (Right click on the folder -> Properties -> Security -> Edit -> Add, and type those in. You can click the 'Check Name' button to ensure it's the correct ones you're typing in)

  3. The next issue you need to tackle is getting a web.config file to put in your server folder to fix routing issues.

If we were working with Apache, we would need an .htaccess, but for IIS, we're using a web.config. The one found here worked for me if your application is routing from the root directory of your server. (Note: As reminded by @Demortes, this will require an additional module to be added to your IIS environment called URLRewrite)

This (web.config) file goes in the root directory of your server.

Hope this helps anyone who had similar issues to me :)

Cheers.

这篇关于如何以及如何将Angular2部署到IIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆