Make Apache 2 Virtual Host Ubuntu 16.04
You are Welcome! The Tutorial Shows You Step-by-Step How to Create Apache 2 Virtual Host in Ubuntu 16.04 Xenial LTS GNU/Linux Server/Desktop.
And the term Virtual Host refers to the Practice of Running more than One Website (such as company1.example.com and company2.example.com) on a Single Machine.
Virtual Hosts can be:
- “Name-based“, meaning that you have Multiple Names running on each IP address
- “IP-based“, meaning that you have a Different IP Address for Every Website
Because the fact that they are running on the same physical server is not apparent to the end user.

How to Create a Name-based Virtual Host on Ubuntu Linux
-
Login into Server Shell.
Or Open a Command Line Terminal Window
(Press “Enter” to Execute Commands)
Ctrl+Alt+T
-
Add the Domain to the hosts Config File
sudo su
If Got “User is Not in Sudoers file” then see: How to Enable sudo
nano /etc/hosts
Append:
127.0.0.1 [myDomainName.com]
Only Substitute Your real Domain Name to “[myDomainName.com]” :)
Ctrl+Shift+v to Paste Content into nano
Ctrl+x to Save and Exit from nano Editor -
Create the VHost Target Directory
mkdir /var/www/html/[mySite]
And may be also a Testing index.html:
echo "The New Web-Site is Working on Apache2!" > /var/www/html/[mySite]/index.html
Then Set the Domain’s Ownership with:
chown -R www-data:www-data /var/www/html/[mySite]
-
Create a VHost Config File
nano /etc/apache2/sites-available/[myDomainName].conf
Append at Least:
<VirtualHost *:80> ServerName [myDomainName.com] ServerAlias www.[myDomainName.com] DocumentRoot /var/www/html/[mySite] </VirtualHost>
To get a little More Insight may look:
cat /etc/apache2/sites-available/000-default.conf
-
Enabling the New Virtual-Host
cd /etc/apache2/sites-enabled
ln -s ../sites-available/[myDomainName].conf .
-
Restart Apache2 Web Server
service apache2 restart
exit
How to Install LAMP Server on Ubuntu Linux
How to Enable Apache2 mod_rewrite Module on Ubuntu
How to Create a IP-based Virtual Host on Ubuntu Linux
How to Create an IP-Based Virtual Host on Ubuntu
Tags: Apache, apache 2, apache 2 virtual host, apache virtual host ubuntu, apache virtual host ubuntu 16.04, apache virtual host ubuntu xenial, Apache Web-Server, create virtual host ubuntu, create virtual host ubuntu 16.04, create virtual host ubuntu xenial, Guide, How-to, Linux, Linux Tutorial, make apache virtual host ubuntu, make apache virtual host ubuntu 16.04, make apache virtual host ubuntu xenial, Ubuntu, Ubuntu 16.04 Xenial tahr, ubuntu linux, ubuntu server, ubuntu tutorial, ubuntu virtual host, virtual host ubuntu, virtual host ubuntu 16.04, virtual host ubuntu xenial, Web Development, Web-Server