Virtual Host Setup: Assign specific website to IP (default)

Posted July 17, 2016 2.2k views
UbuntuLAMP StackDigitalOcean

I just setup my droplet as a virtual host (LAMP + Ubuntu) and successfully added 5 websites! win! However, it seems to have chosen one of the five as the default when I visit my IP address directly. Is there a way to specify which site inside of /var/www/ the IP should default to?

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.

Submit an Answer
1 answer

Look for the VirtualHost blocks in /etc/apache2/sites-enabled that you want to set as the default. Make the following change(s)

<VirtualHost  *:80>   or <VirtualHost *:443>


<VirtualHost _default_:80>   or  <VirtualHost _default_:443>

Make sure only one virtual host block is assigned the default (max one default per port). As you may already know, http URLs are usually assigned to port 80 and https URLs to port 443.