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.
Of course you have to serve it on the server. There are a few steps you have to take:
npm install
inside your app's directory.app.js
(or whatever) to bind to your internet interface. The default is to have it bind tolocalhost
so you won't be able to access it from outside your local.root
user, which is not recommended. Try open the port with a iptables command like:iptables -A INPUT -p tcp --dport 9000 -j ACCEPT
ng serve
(or whatever)This instructions are for development, not for production use.
You will have to build the app, have a look in package.json in the app root. You will normally have build dev/prod or something along those lines. Then just copy the contents of the dist folder up to the server and make sure that scrips src are correct in the index. file.
On your local development machine do an
ng build --prod
orng 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.