How do i Host 2 Websites in One Droplets with sub folder

August 13, 2017 123 views
Apache Ubuntu 16.04 Ubuntu

i want to host first 2 domain in single droplet like
domain1.com => /var/www/html/

2 Answers


This is very easy using apache virtual hosts

Follow these instructions to achieve what you want

  • Copy the default apache site and give it another name using this command: sudo cp /etc/apache2/siates-available/000-default.conf /etc/apache2/sites-available/domain1.com.conf
  • Modify the default configuration by changing the following options:
    • ServerName domain1.com
    • ErrorLog ${APACHE_LOG_DIR}/domain1.com_error.log
    • DocumentRoot /var/www/html/
    • CustomLog ${APACHE_LOG_DIR}/domain1.com_access.log combined
  • Repeat step one and name the file as domain2.com.conf
  • Repeat step two and replace domain1.com with domain2.com also do not forget to change DocumentRoot to /var/www/html/admin
  • Enable the two new sites with these two command: sudo a2ensite domain1.com.conf, domain2.com.conf.
  • Restart apache with this command sudo service apache2 restart

Now you can use domain1.com to access the site at /var/www/html and domain2.com to access the site at /var/www/html/admin

Hope this helps, revert back here for any further questions.

When using the Nginx web server, server blocks (similar to the virtual hosts in Apache) can be used to encapsulate configuration details and host more than one domain off of a single server. In this guide, we'll discuss how to configure server blocks in Nginx on an Ubuntu...
Have another answer? Share your knowledge.