Report this

What is the reason for this report?

Multiple Websites on a Single Droplet

Posted on September 1, 2019

Hey.

I’m aware that this question has some detailed answers on many platforms including Digital Ocean Community, but the thing is, as far as I come along they are a bit outdated currently (Please feel free to correct me as I would much appreciate it). There are 3 suggestions right now in the “Do any of these answer your question?” section and the closest date is from 4 years ago.

So, here’s my exact details about my situation;

I deployed a Ubuntu 18.04 droplet, installed Apache2 for web server, then installed MySQL and PHP. So it’s a LAMP stack.

I’ve used these following pages and they were great. Thanks to all of their authors.

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04

I need to learn managing multiple wordpress sites in this droplet, each will have their own domains. Digital Ocean has a Wordpress tutorial in here (https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-18-04) which I also will follow along but since it doesn’t cover creating multiple sites, here’s my attempt to ask for resource advice.

Thank you and wish you all a great day.



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.

Hey,

So Ubuntu 16.04 tutorials are also valid for Ubuntu 18.04 , right?

Hello,

You can host multiple websites on one droplet by adding multiple Apache Virtual Hosts.

Here’s a step by step article on how to do that:

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04

Let me know if you have any questions.

Regards, Bobby

Running multiple websites on a single droplet (or server) is a common scenario, especially when you’re trying to optimize resources. You can achieve this by setting up Virtual Hosts in Apache or Server Blocks in Nginx. Here’s a guide on how to do this:

Prerequisites:

  • A droplet/server with a Linux distribution (e.g., Ubuntu, CentOS).
  • A web server installed (Apache or Nginx).
  • Domain names for each website.
  • Basic understanding of SSH and server administration.

Setting Up Multiple Websites with Apache

1. Install Apache (if not already installed)

sudo apt-get update
sudo apt-get install apache2

Configure Virtual Hosts

  • Apache uses Virtual Hosts to manage multiple websites on a single server. Each website will have its own Virtual Host file.

  • Create a directory for each website:

sudo mkdir -p /var/www/yourdomain1.com/public_html
sudo mkdir -p /var/www/yourdomain2.com/public_html
  • Replace yourdomain1.com and yourdomain2.com with your actual domain names.

  • Set Permissions:

sudo chown -R $USER:$USER /var/www/yourdomain1.com/public_html
sudo chown -R $USER:$USER /var/www/yourdomain2.com/public_html
sudo chmod -R 755 /var/www

Create Virtual Host Configuration Files:

sudo nano /etc/apache2/sites-available/yourdomain1.com.conf
<VirtualHost *:80>
    ServerAdmin webmaster@yourdomain1.com
    ServerName yourdomain1.com
    ServerAlias www.yourdomain1.com
    DocumentRoot /var/www/yourdomain1.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/yourdomain1.com-error.log
    CustomLog ${APACHE_LOG_DIR}/yourdomain1.com-access.log combined
</VirtualHost>

Repeat the process for the second domain

Enable the Virtual Hosts:

sudo a2ensite yourdomain1.com.conf
sudo a2ensite yourdomain2.com.conf
  • sudo systemctl restart apache2

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.