Apache virtual Host on Ubuntu 20.04

Based on https://httpd.apache.org/docs/2.4/vhosts/index.html The term Virtual Host refers to the practice of running more than one web site (such as company1.example.com and company2.example.com) on a single machine.

Next i will demonstrate how to make simple virtual host.

  1. Install apache on ubuntu

Follow the instruction on this link : https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-20-04

2. I prefer to change the default http port

Go to /etc/apache2/sites-available directory then $ sudo gedit 000-default.conf.

Change port 80 to be 8082

3. Create new directory on /var/www/html/. /var/www/html/ is base directory for project location

create new project directory

Create new file index.php

create new index.php

Put the code on index.php

4. Create new virtual host configuration for project telo.com

cretae new config file

put following code in telo.com.conf file

for information detail about telo.com.conf content please refer to https://httpd.apache.org/docs/current/vhosts/

5. Activate the configuration

Reload configuration and restart apache

6. Configure etc host.

Add configuration to etch host, the syntax is : IP_ADDRESS space HOSTNAME for example testonly.com

Find your ip add by ip a command

ip address in server / laptop

on /etc directory type

Then add following cod to hosts

7. Test the result

Access http://telo.com:8082







i am a reader