How does one run a node.js app on a VPS server that was setup with the LAMP stack?

122 views
Skip to first unread message

Bruce Whealton

unread,
Jan 16, 2015, 6:21:25 PM1/16/15
to nod...@googlegroups.com
Hello all,
            I'm trying to figure out how to deploy and run a node.js app on my vps server.  I have vps hosting.  I have been using NGINX... previously I was using Apache but decided NGINX would work better.  Anyway, I'm trying to figure out how to run a Full Stack JavaScript environment in addition to the regular LAMP stack - I guess it is a LEMP stack, actually.  
            I've done some searches on this but it is hard to find an answer to what I am trying to do.  I hear about platforms for hosting node.js apps but since I already pay for a VPS hosting plan, I'd like to see if it is possible to run a node.js server somehow.  Would I need to run it on a different port?  I read somewhere about using a configuration that would direct a sub-domain to use a node server.  Maybe I need to get a different IP address from my provider.  The other IP address would be used for the node server.  I guess in this scenario, I'd need to setup my DNS to map the different IP to the sub-domain.  Even as I write this right now, this doesn't make sense really.  I do have an extra domain that I could use for my node based server (which would use the MEAN stack).
Can anyone provide any tips or directions for this?
Thanks,
Bruce

Ryan Schmidt

unread,
Jan 16, 2015, 8:35:10 PM1/16/15
to nod...@googlegroups.com
Often, people use nginx in front of nodejs. In other words, nginx will run on port 80 on your public IP address and that's what users will communicate with. In addition, you run nodejs on a private port number, such as 3000, open only to localhost, and nginx is configured to talk to that when necessary to reach your app. You can run any number of such apps, each on their own ports (e.g. 3001, 3002), and the single nginx instance talks to them as needed. You can additionally configure nginx to handle the static content (e.g. images, stylesheets) while passing dynamic requests to your app. nginx can handle compression and tls encryption for you. nginx can even cache dynamic requests from your app, if your app sends applicable caching headers allowing it to do so. You can restart your node apps independently of one another as needed to reload them with new code, without affecting the other apps. Each app can use the cluster module and spawn as many instances as you think are likely to be needed by that particular app.

By searching Google for "nginx node" you should be able to find many guides showing how this kind of thing can be set up.

Reply all
Reply to author
Forward
0 new messages