Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How and what to deploy Angular2 to IIS

Tags:

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.

like image 829
user2355785 Avatar asked Feb 17 '16 14:02

user2355785


People also ask

Which server is used to deploy Angular?

Angular is an app-design framework and development platform for creating efficient and sophisticated single-page apps. Normally angular applications are developed using the NodeJS server and by installing Angular CLI on it. We can package out the build of an application and run it over any server.


1 Answers

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.

like image 69
jarodsmk Avatar answered Oct 10 '22 17:10

jarodsmk