By MarkSu
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?
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!
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;
server_name node.yourdomain.com;
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 wordpress.yourdomain.com it will go to your wordpress site. If the request is instead or node.yourdomain.com 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 yourdomain.com and any directories under it would go to wordpress unless the request is under yourdomain.com/node. Anything in that path would be routed to your node service.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.