I want to deploy the nodejs files to web server, for the time being, i was run like this node server.js through command prompt. how to run the nodejs always and without command prompt. please suggest.
-
1Which is the system operation mounthed on server?Filippo1980– Filippo19802016-11-17 10:46:52 +00:00Commented Nov 17, 2016 at 10:46
-
@Filippo1980, apache cpanelMoses bendicion– Moses bendicion2016-11-17 11:05:55 +00:00Commented Nov 17, 2016 at 11:05
-
That's not an operating system, Moses, that's an application management web app that can be installed on many different operating systems.Paul– Paul2016-11-17 11:31:37 +00:00Commented Nov 17, 2016 at 11:31
-
For deploy you can use PM2, and for automatic start systemd.Hosar– Hosar2016-11-21 02:19:22 +00:00Commented Nov 21, 2016 at 2:19
1 Answer
To deploy node.js app, you pretty much need shell access. You have to run node.js somehow. So, typical web-host does not work, you need rights to run your own process. If you are running host yourself, then you are looking for process manager, for example supervisor or pm2.
There is some node.js hosting services too, some good ones listed here. All hosting providers give you instructions how to deploy node.js on their platform so I'm not going to cover that (some examples: Heroku, Digital Ocean). Especially Digital Ocean have a lot of good tutorials, worth of reading, even if you are using some other hosting.
That being said, are you sure you have Node.js app? Node.js is often used in client-side workflows too, so it's possible your app could be deployed using cPanel. If you are just using node.js to run webpack-dev-server, for example, changes are you have just client-side app and it can be deployed on regular http-server, like Apache. If that's the case, your build process most likely produce dist folder which contains html, css and js to upload to our server's document root.