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!
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!
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.
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
orapt-get
(CentOS will useyum
while Debian & Ubuntu useapt-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 thesudo
package first and then proceed with the remaining commands. If you choose Ubuntu, simply omit the first command.Installs
sudo
:Installs
nginx
:Installs
php-fpm
:Installs
mariadb
(a fork of MySQL):The NGINX configuration file will be located at:
An example server block configuration can be found in:
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:
And to ensure PHP-FPM is running:
–
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.
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.
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.
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?
And the other one would be:
I’ve tried it and it didn’t really work :(