🔀How To Configure VirtualHost DNS Server With Apache2

Introduction
Virtual hosting is a method for hosting multiple domain names on one server. This allows a single server to share its resources, such as memory and processor cycles, without requiring all provided services to use the same hostname.
Apache is one of the favorite and widely used web servers because it is a powerful web server, and is easy to integrate with many platforms such as cPanel, Plesk, VestaCP, etc. By default, the web server can only use one domain. Therefore, the Apache web server has a special configuration called Virtual Host. Virtual host is a configuration on a web server that allows you to use more than one domain on a server. With a virtual host you can create more than one website with different content on a server.
Configuration
Debian11- Router
Edit DNS Server
cd /etc/bind
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA rizwanpemula.com. root.rizwanpemula.com. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns1.rizwanpemula.com.
@ IN A 20.1.1.1
@ IN NS rizwanpemula.com.
@ IN A 20.1.1.20
ns1 IN A 20.1.1.1
www IN A 20.1.1.20
myweb IN A 20.1.1.20
mail IN A 20.1.1.20
php IN A 20.1.1.20
phpmyadmin IN A 20.1.1.20
wordpress IN A 20.1.1.20
static IN A 20.1.1.20
dinamis IN A 20.1.1.20
dvwa IN A 20.1.1.20
Restart DNS Service
systemctl restart bind9
Debian11- Server
Create Directory
Add a directory to store the virtualhost file di /var/www/
cd /var/www
mkdir static dinamis dvwa myweb wordpress php
Copy file VirtualHost
cd /etc/apache2/sites-available/
cp 000-default.conf myweb.conf
cp 000-default.conf static.conf
cp 000-default.conf dinamis.conf
cp 000-default.conf dvwa.conf
Configuration VirtualHost File
ServerName myweb.rizwanpemula.com
ServerAdmin [email protected]
DocumentRoot /var/www/myweb
Enable Configuration
a2ensite static.conf dinamis.conf dvwa.conf myweb.conf
systemctl reload apache2
Last updated