Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy a simple Angular2 app on a shared hosting? [closed]

I'd like to deploy my Angular2 app on my shared hosting. I tried transferring the files via ssh, but the app doesn't run. I guess there is something to do like the ng serve on local.

What do are the steps to follow ? I couldn't find them on the internet :/

Thanks

EDIT

I have a very simple app with a few routes and components. No serverside code since I'm calling my REST api for my needs.

like image 745
Fab Avatar asked Dec 08 '22 20:12

Fab


1 Answers

On your local development machine do an ng build --prod or ng build --prod --aot

This will build your app into the dist folder. Copy the contents of your dist folder to the public directory of your shared hosting.

Depending on your hosting you may need to configure a web server (nginx, Apache, IIS, etc) to serve your files. Don't run ng serve on your shared hosting.

Unless you plan on running your application in Universal mode, where it rerenders pages server side, do not copy your entire app to your shared host. Do not do an npm install on your shared host. Just copy the built application files in the dist folder.

like image 93
Martin Avatar answered Dec 10 '22 12:12

Martin