Can I run LEMP Server and a Node stack on the same droplet?

December 17, 2017 738 views
LEMP Node.js Nginx Ubuntu 16.04

I just setup a LEMP server on Ubuntu 16.04. This is my first time setting up a server from scratch!

I would like to run 3 seperate domains on the same droplet. One is a LEMP site (personal site) and another is a Node.js app that I want to use Node/Express/React/Postgres on. The third one might be a wordpress blog. Anyway...

Two Questions:

1

I have already created the server blocks for the respective sites. Do I just install all my necessary packages and go from there? Can node and node packages be installed alongside mysql and php?

2

Do server blocks share all the same access to the packages/servers I install? For example, can all domains use mysql and php or node?

1 Answer
JonsJava December 21, 2017
Accepted Answer

Think of it this way:

Can this road handle 100,000 cars per hour with no bottle necks?

There are a lot of questions to ask:

  • Was the road built optimally (code for the sites)?
  • Is the road wide enough (memory allocation per request)?
  • Are there enough lanes (server size)?
  • Does it have shoulders to allow people to pull over if they break down (CPU/RAM is able to handle extra load/larger requests)?

So, think of planning a server the way you would a road. Can it handle the traffic? Can it handle 25% more traffic than you expect? Is your code optimized?

As for if the sites can use the same installs of packages: yes.

  • Hi JonsJava, Thanks for your response!

    This is really my first time trying to self-manage my environment. So I am not yet at the level of fine-tuning. It takes quite a lot of skill and experience!

    I ended up having no trouble setting up the server blocks and directives. DO has excellent tutorials and knowledge base. And did realize the packages etc were globally available and are in general fine to install alongside each. However, it is like you said it's mostly if the server itself can handle the load...

    The very first problem I ran into was definitely my server size. I chose a 512mb droplet to handle these scenarios... I didn't realize node.js applications required minimum 1GB. Otherwise, I'd have to employ some type of swap memory which DO advises against. So I ended up moving to the next size up to host my dinky apps. Hopefully it will work out. It was mostly the RAM that was an issue in this case for the node app.

    I ended up deciding to move my wordpress blog to its own LAMP droplet, to keep it separate but also to handle the traffic. So in this case CPU might be an issue.

    I am now working on a different hurdle regarding hosting my node apps on a subdomain and in a subdirectory on the LEMP server! I cannot tell if it's my server block config or my Express routes or Webpack. But I am now wrestling how to deploy a node.js application to a subdirectory properly!

    Anyway, thanks again for your response! And Happy New Year!

Have another answer? Share your knowledge.