2

First of all, my question is not about how to install angular. I'm just getting started with this framework and already got a question right at the beginning.

Usually I create new web projects (HTML, PHP...) in the default web folder of the apache webserver (/var/www/). I did this with angular too under /var/www/firstAngularProject, but it seems the application itself is only accessible on its default port on the webserver root. In my case this is localhost:4200

When I try to open the path in my browser localhost/firstAngularProject I see the index structure and I think this could become a security issue.

So my question is where should I install the angular project or what is the usual way to install it?

Ian Fako
  • 1,148
  • 1
  • 15
  • 34

1 Answers1

4

When you run Angular using the cli command ng start (which I assume, based on you describing using localhost:4200) you're running the application using webpack-dev-server. This is undesirable since it's only meant for use during development, not for production.

In production Angular works just like any other frontend framework. You build the application with ng build --prod which produces a number of build artifact (in the /dist folder). These artifact are simply static files you make available through some webserver, in your case Apache, by copying the content of the /dist folder to /var/www (or whichever is your default web folder) and that's about it.

Nikolaj Dam Larsen
  • 5,455
  • 4
  • 32
  • 45