Question

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

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

Subscribe
Share

Submit an 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.

@yWalker

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.