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.
- 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.
3. Create new directory on /var/www/html/. /var/www/html/ is base directory for project location
sudo mkdir telo.com
Create new file index.php
Put the code on index.php
<?php echo “<p>Hello welcome to telo.com</p>”; ?>
4. Create new virtual host configuration for project telo.com
sudo gedit telo.com.conf
put following code in telo.com.conf file
<VirtualHost *:8082>
ServerName telo.com
DocumentRoot /var/www/html/telo.com
<Directory /var/www/html/telo.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/telo.com_error.log
CustomLog /var/log/apache2/telo.com_access.log combined
</VirtualHost>
for information detail about telo.com.conf content please refer to https://httpd.apache.org/docs/current/vhosts/
5. Activate the configuration
sudo a2ensite telo.com.conf

after activation we will see similar configuration in directory sites-enabled with di rectory sites-available. after using ls -la command we see that file in site-enabled directory has symbolic link to file in site-available directory.
Reload configuration and restart apache
sudo systemctl reload apache2sudo systemctl restart apache2
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
on /etc directory type
sudo gedit hosts
Then add following cod to hosts
192.168.1.6 telo.com
7. Test the result
8. configure another virtual host, example : helloword.web:
create file hello-world.conf on /etc/apache2/sites-available then the contain of the file should be like this :
<VirtualHost *:8082>
ServerName helloworld.web
DocumentRoot /var/www/html/test
<Directory /var/www/html/test>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/helloworld.web_error.log
CustomLog /var/log/apache2/helloworld.web_access.log combined
</VirtualHost>
activate the config with :
sudo a2ensite hello-world.conf.conf
modify the host :
192.168.1.6 helloword.web
then restart apache :
sudo systemctl reload apache2sudo systemctl restart apache2

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/