If you are hosting more than one site on a server, then you most likely use Apache’s virtual host files to state which domain should be served out. Name based virtual hosts are one of the methods used to resolve site requests. This means that when someone views your site the request will travel to the server, which in turn, will determine which site’s files to serve out based on the domain name. Using this method you’ll be able to host multiple sites on one server with the same IP. In this tutorial, we’ll show you how to set up your virtual host file for each of your domains on an Ubuntu 18.04 VPS server.

Preflight

  • Login in as root

Step 1: Make a Directory for Each Site

You’ll create a directory for each site that you’ll be hosting, within the /var/www folder. This location newly created location is also dubbed the document root location; you’ll need to set this path later in the configuration file. Sub the domain.com and domain2.com for your domain names.

mkdir -p /var/www/**domain.com**/public_html

mkdir -p /var/www/**domain2.com**/public_html

Step 2: Set Folder Permissions

chmod -R 755 /var/www

Step 3: Set up an Index Page

To see a home page you’ll want to make sure the** index.html** file is created for each domain. Something as simple as “testing for domain.com” can be set within this file.

#tutorials #a2ensite #apache2 #configuration #hosts #site #virtual host

Host Mutilple Sites on One Server Using Apache | Liquid Web
1.35 GEEK