Wordpress (PHP & MYSQL) + Node JS & MongoDB in one droplet

Hi there,

I am looking to host a my SaaS service in digitalocean’s droplet. The main system will be done in JS with MongoDB as the database. However I would like a “blog” page which runs on wordpress (PHP & MYSQL). My question is, " Is it possible to host 2 of these architecture in one droplet?" Or it requires 2 droplet to run 2 different environment?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This should be possible. Here is what I would recommend.

1.) Configure a LEMP stack (nginx instead of Apache as the web server) or use the LEMP one-click image to start.

2.) Install and configure node and MongoDB as you normally would.

3.) Assuming that you will be using separate domain or subdomain names for your node and wordpress sites you will want to create a second server block in your nginx configuration file /etc/nginx/sites-enabled/default that will redirect the traffic for your second site to the node server.

First add a server_name variable to your existing server block (if you have not already) which has the domain/subdomain name used for your Wordpress site.

Then add your second server block:

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;


location / {
    proxy_pass       http://localhost:8000;
    proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;


Make sure to set the server_name variable to your domain/subdomain and the port in the proxy_pass variable to the port that node is listening on.

Now when a user visits your droplet via either domain/subdomain the request is processed by nginx. If the request is for it will go to your wordpress site. If the request is instead or it would be proxied to your node server.

If you want these to live on the same domain instead of two separate ones you would just want to add a second location block to the configuration for your wordpress site like the one shown below:

location /node/ {
    proxy_pass       http://localhost:8000;
    proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;

With this configuration, requests for and any directories under it would go to wordpress unless the request is under Anything in that path would be routed to your node service.