Question

Hosting multiple platforms on single droplet.

Hello,

I would like to use Digital Ocean to host my online portfolio and I am wondering if it is possible to serve multiple web applications / pages from different server side platforms (node, php, java) through a single droplet.

I was thinking about using sub-domains like node.mydomain.com, java.mydomain.com, or php.mydomain.com pointing to different application containers on the Linux droplet, but im not sure if this is the most efficient way or even possible. Also open to using different routes like mydomain.com/node, mydomain.com/php, and mydomain.com/java.

Am I needing to work with Apache? Port numbers? Routes? VPN?

Looking forward to receiving advice from the community or a Digital Ocean representative.

Thanks!

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.

@andrewcrayden

You can definitely setup a Droplet and configure Apache/NGINX/Caddy/[insert-web-server] as your web server and run PHP, NodeJS, Python, Java or [insert-programming-language] as well. The only thing you’d need to keep in mind is the requirements for each.

If you’re going to run multiple environments, make sure you have the resources to handle them. I’d recommend at least a 2GB Droplet if this is the plan, especially if you plan on also using a database server (such as MySQL, MariaDB, Percona, Postgres etc).

The vast majority can be setup from the CLI using repository packages and either yum or apt-get (CentOS will use yum while Debian & Ubuntu use apt-get).

For example, to install NGINX + PHP-FPM on Debian/Ubuntu with support for MySQL (or any fork of MySQL, such as MariaDB / Percona), you’d issue the following commands from the CLI:

NOTE: Debian does not pre-install sudo, the package must be installed first. This isn’t required for Ubuntu. So if you choose Debian, you’d issue the first command to install the sudo package first and then proceed with the remaining commands. If you choose Ubuntu, simply omit the first command.

Installs sudo:

apt-get install -y sudo

Installs nginx:

sudo apt-get install -y nginx

Installs php-fpm:

sudo apt-get install -y php5-cli php5-fpm php5-dev php5-common php5-mysqlnd

Installs mariadb (a fork of MySQL):

sudo apt-get install mariadb-server

The NGINX configuration file will be located at:

/etc/nginx/nginx.conf

An example server block configuration can be found in:

/etc/nginx/sites-available/

At this point, you would need to configure NGINX to utilize PHP by editing the server block (see the default example in the above directory for a basic guide) and then restarting NGINX:

sudo service nginx restart

And to ensure PHP-FPM is running:

sudo service php5-fpm start

Of course, there’s more to be done and this isn’t an all-inclusive guide. rather, a simple one to show you how to go about getting started without having to manually configure NGINX & PHP (though you can do that as well, it’s just a bit more time consuming).

Hi there! Yes, you can definitely do this. You will have to work with Apache (or any other web server [eg:- Nginx]). Please look up “Virtual Hosts”. I gathered a small list of existing DigitalOcean tutorials that could be of help to you. Do let me know if you need anything else.

  1. https://www.digitalocean.com/community/tutorials/how-to-set-up-multiple-wordpress-sites-on-a-single-ubuntu-vps This link talks about wordpress sites on an ubuntu server (you havent mentioned what server youre using but this tutorial involves – apache, ubuntu, wordpress.

  2. https://www.digitalocean.com/community/tutorials/how-to-host-multiple-websites-securely-with-nginx-and-php-fpm-on-ubuntu-14-04 This link is the tutorial answer to the question you asked, except it uses Ubuntu and Nginx Nginx is considered to be for slightly advanced users, so you would wanna check out apache first.

  3. https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts This link talks to you about setting up apache virtual hosts - as i mentioned earlier.

To conclude, I think that a thorough reading of all the three links should give you a firm answer to your question. Let me know if you need anything else.

Could it be done with the same domain but having different routes?

<VirtualHost *:80>
    ServerAdmin admin@something.com
    ServerName mydomain.com/project_1
    ServerAlias www.mydomain.com/project_1
    DocumentRoot /var/www/test.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

And the other one would be:

<VirtualHost *:80>
    ServerAdmin admin@something.com
    ServerName mydomain.com/project_2
    ServerAlias www.mydomain.com/project_2
    DocumentRoot /var/www/test.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I’ve tried it and it didn’t really work :(