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

127.0.0.1 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

source

https://httpd.apache.org/docs/current/vhosts/

https://musaamin.web.id/cara-install-laravel-8-ubuntu-2004/

https://websiteforstudents.com/change-apache2-http-default-port-on-ubuntu-16-04-17-10-18-04/

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04

https://www.techomoro.com/how-to-run-a-php-application-on-ubuntu-18-04-2-lts/

i am a reader