How to Configure Apache Virtual Hosts on Ubuntu 20.04 - 22.04

preview_player
Показать описание
The virtual hosting concept is used by companies to host multiple websites using a single machine. It can be achieved either by an ‘IP-based’ method or a ‘name-based’ approach. In ‘IP-based’ hosting we have distinct IP addresses for each website. In the case of ‘name-based’ hosting, we have multiple names running on each IP address.

In this Video, we will see how we can host two virtual hosts on an Ubuntu 20.04 - 22.04 system using name-based virtual hosting. We will use the Apache web server.

Useful Links:

WARNING - ANGLED BRACKETS AREN'T ALLOWED IN DESCRIPTION SO BE ATTENTIVE TO THE VIDEO IN NANO REDACTOR

Commands Used:
sudo apt install apache2 -y
sudo systemctl restart apache2
sudo systemctl status apache2
sudo mkdir -p /var/www/host1/public_html
sudo mkdir -p /var/www/host2/public_html
sudo chown -R $USER:$USER /var/www/host1/public_html
sudo chown -R $USER:$USER /var/www/host2/public_html
sudo chmod -R 755 /var/www

VirtualHost *:80

ServerName host1

DocumentRoot /var/www/host1/public_html

/VirtualHost

VirtualHost *:80

ServerName host2

DocumentRoot /var/www/host2/public_html

/VirtualHost

sudo apache2ctl configtest
sudo systemctl reload apache2
Рекомендации по теме