Host Multiple Websites on a Single Ubuntu Droplet (16.04–24.04)
This guide shows you how to host multiple websites on one Ubuntu server (Droplet/VPS) using a LAMP stack (Linux, Apache, MySQL/MariaDB and PHP). It works for Ubuntu 16.04, 18.04, 20.04, 22.04 and 24.04.
I use this setup to run many WordPress sites on the same server — each with its own domain, document root, and database — without paying for separate hosting accounts per site. The key is using Apache virtual hosts and a tidy folder structure.
1) (Optionally) install a LAMP stack on your Ubuntu server
2) Create a separate web root for each domain
3) Create Apache virtual hosts per domain
4) Point DNS records at your server
5) Upload WordPress or static files for each site
6) Fix file permissions
7) (Optional) Add HTTPS with Let's Encrypt
8) Repeat the pattern for more sites
Step 0 – Install LAMP (per Ubuntu version)
If you already have Apache, MySQL/MariaDB and PHP installed and serving at least one site, you can skip this step. Otherwise, pick your Ubuntu version below and run each command line by line.
Ubuntu 16.04 – LAMP
sudo apt-get updatesudo apt-get install apache2 mysql-server php libapache2-mod-php php-mysql unzip -ysudo mysql_secure_installationsudo systemctl enable apache2 mysqlUbuntu 18.04 – LAMP
sudo apt updatesudo apt install apache2 mysql-server php libapache2-mod-php php-mysql unzip -ysudo mysql_secure_installationUbuntu 20.04 – LAMP
sudo apt updatesudo apt install apache2 mysql-server php libapache2-mod-php php-mysql unzip -ysudo mysql_secure_installationUbuntu 22.04 – LAMP
sudo apt updatesudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql unzip -ysudo mysql_secure_installationUbuntu 24.04 – LAMP
sudo apt updatesudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql unzip -ysudo mysql_secure_installationStep 1 – Create folder structure per domain
For each website/domain, create a dedicated directory under /var/www.
In this example we'll use example.com (replace with your domain):
sudo mkdir -p /var/www/example.com/public_htmlsudo chown -R www-data:www-data /var/www/example.comsudo chmod -R 755 /var/www/example.comRepeat for each domain you plan to host: secondsite.com, thirdsite.com, and so on.
Step 2 – Create Apache virtual host
Create a new Apache vhost file for your domain:
sudo nano /etc/apache2/sites-available/example.com.confPaste this configuration (copy button will copy the whole block):
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
AllowOverride All
Require all granted
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
Enable the site and reload Apache:
sudo a2ensite example.com.confsudo systemctl reload apache2/var/www, a new *.conf
vhost file, then enable the site and reload Apache.
Step 3 – Configure DNS for each domain
At your domain registrar or DNS provider, create an A record for each domain you want to host:
example.com → your-server-ipwww.example.com → your-server-ip(optional but recommended)
Once DNS propagates, visiting http://example.com will hit your droplet and Apache will choose the correct vhost.
Step 4 – Upload your site (WordPress or static)
Each site now has its own document root, for example:
/var/www/example.com/public_html. Upload your site files there:
- For WordPress: place WordPress files in
public_htmland follow your WordPress install guide. - For static sites: upload your HTML/CSS/JS to
public_html.
Repeat for each domain using its own public_html folder.
Step 5 – Set permissions
Make sure Apache can read/write where needed:
sudo chown -R www-data:www-data /var/www/example.comsudo chmod -R 755 /var/www/example.comDo the same for each site directory you add.
Step 6 – (Optional) Add SSL with Let’s Encrypt
Once your sites are working over HTTP, you can secure each domain with free SSL certificates from Let's Encrypt. I have a separate guide that covers Ubuntu 16.04–24.04 and both Apache and Nginx:
How to Install Let's Encrypt SSL on Ubuntu (16.04–24.04) – Apache & Nginx Guide
Get $200 Free DigitalOcean Credit
If you don't already have a DigitalOcean account, you can get $200 free credit using my referral link below:
Click here to claim $200 DigitalOcean credit
I use this exact multi-site on one droplet setup for many of my own sites, and DigitalOcean makes it easy to scale as you grow.





