Installing LEMP and MEAN stacks on single droplet?

Howdy all,

I’m switching from a shared host to Digital Ocean, but want to try the waters with the 5$ plan for a bit first.

I will just be porting over my personal portfolio/blog (PHP, AnchorCMS) so I will need the LEMP stack.

I also hav a couple of small side projects I am working on using Node.JS / MEAN stack, which I would love to host with the same 5$ droplet.

Is it possible/simple to configure both stacks to operate on the same droplet without breaking anything? Are there any guides or tutorials for this?

Thanks for any help!

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.

It should be fine to have both set ups on a single droplet. We have tutorials going through both setups:

You can either start with a fresh Ubuntu base install and follow those tutorials or start with one of the “applications” and install the other along side it.

The one thing to keep in mind is that only one process can bind to port 80 at a time. So in order to run both sites, you’ll need to set up your MEAN app to run behind an Nginx reverse proxy.

You Nginx configuration might look something like this:

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

	root /var/www/html;
	index index.php index.html index.htm;


	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;

	error_page 404 /404.html;
	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
		root /usr/share/nginx/html;

	location ~ \.php$ {
		try_files $uri =404;
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_pass unix:/var/run/php5-fpm.sock;
		fastcgi_index index.php;
		include fastcgi_params;

upstream mean_app{

	listen 80;
	listen [::]:80 ipv6only=on;


    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://mean_app/;
      proxy_redirect off;

A couple things to note here. This assumes the MEAN app is running on port 3000. Update that as needed. Also, the server_name directive is important here. It’s how Nginx know how to route requests to the correct app.

Let us know how it goes!