• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to implement Name Based Virtual Host on Debian 11.3

  • 00:28 lsb_release -a
  • 00:36 sudo -s
  • 00:42 cd /
  • 00:51 apt install apache2
  • 01:10 systemctl start apache2
  • 01:23 systemctl status apache2
  • 02:11 cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example1.com.conf
  • 02:52 cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example2.com.conf
  • 03:28 nano /etc/apache2/sites-available/example1.com.conf
  • 04:15 nano /etc/apache2/sites-available/example2.com.conf
  • 04:51 mkdir /var/www/html/example1
  • 05:15 mkdir /var/www/html/example2
  • 05:33 nano /var/www/html/example1/index.html
  • 06:49 nano /var/www/html/example2/index.html
  • 07:58 a2ensite example1.com.conf
  • 08:10 a2ensite example2.com.conf
  • 08:28 systemctl restart apache2
  • 08:42 nano /etc/hosts
  • 09:40 systemctl restart apache2
{{postValue.id}}

To Implement Name Based Virtual Host on Debian 11.3

Introduction

In Apache, virtual hosting is the concept of hosting multiple sites within a single server, there are two types of virtual hosting, IP address hosting and domain hosting, so we can host either IP addresses or domain names.

Installation Procedure:

Step 1 : Check the OS version by using the below command

linuxhelp@linuxhelp:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye

Step 2 : Change as root user by using the below command

linuxhelp@linuxhelp:~$ sudo -s

Step 3 : Change the directory to root by using the below command

root@linuxhelp:/home/linuxhelp# cd / 

Step 4 : Installing apache web server

root@linuxhelp:/# apt install apache2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
0 upgraded, 8 newly installed, 0 to remove and 254 not upgraded.
Need to get 1,739 kB of archives.
After this operation, 7,550 kB of additional disk space will be used.

Step 5 : Next start and Check the Status from apache2 by using the below commands

root@linuxhelp:/# systemctl start apache2
root@linuxhelp:/# systemctl status apache2

Step 6 : Open the browser and ping the IP address as shown in the below image snap 1

Step 7 : Copying the default virtual host .conf file example1.com virtual host

root@linuxhelp:/# cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example1.com.conf

Step 8 : Copying the default virtual host .conf file example2.com virtual host

root@linuxhelp:/# cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example2.com.conf

Step 9 : Configure the virtual host for example1.com

root@linuxhelp:/# nano /etc/apache2/sites-available/example1.com.conf 

snap 2

Step 10 : Configure the virtual host for example2.com

root@linuxhelp:/# nano /etc/apache2/sites-available/example2.com.conf

snap 3

Step 11 : Making document Root directory as example1

root@linuxhelp:/# mkdir /var/www/html/example1

Step 12 : Making document Root directory as example2

root@linuxhelp:/# mkdir /var/www/html/example2

Step 13 :Making the index.html file for example1.com

root@linuxhelp:/# nano /var/www/html/example1/index.html

snap 4

Step 14 : Making the index.html file for example1.com

root@linuxhelp:/# nano /var/www/html/example2/index.html

snap 5

Step 15 : Enabling virtual host site example1.com.

root@linuxhelp:/# a2ensite example1.com.conf
Enabling site example1.com.
To activate the new configuration, you need to run:
  systemctl reload apache2

Step 16 : Enabling virtual host site example2.com.

root@linuxhelp:/# a2ensite example2.com.conf
Enabling site example2.com.
To activate the new configuration, you need to run:
  systemctl reload apache2

Step 17 : Restart the apache server

root@linuxhelp:/# systemctl restart apache2

Step 18 : Put host entries for virtual hosts

root@linuxhelp:/# vi /etc/hosts
192.168.6.137 www.example1.com
192.168.6.137 www.example2.com

Step 19 : Restart the apache server

root@linuxhelp:/# systemctl restart apache2

Step 20 : Next Go to the Browser Ping the www.example1.com snap 6 Step 21 : Open new tab Ping the www.example2.com snap 7

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to Implement Name Based Virtual Host on Debian 11.3. Your feedback is much welcome.

Tags:
michael
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is a virtual host example?

A

Name-based virtual hosts use multiple hostnames for the same IP address. For instance, a blog server may host both blog1.example.com and blog2.example.com. The biggest issue with name-based virtual hosting is that it is difficult to host multiple secure websites running SSL/TLS.

Q

How many virtual hosts can Apache handle?

A

If each virtual host has its own log, the limit is likely 64 due to file descriptor limits. However, you can configure Apache to run more using this guide

Q

Where is the Apache virtual host file?

A

By default, on Ubuntu systems, Apache Virtual Hosts configuration files are stored in /etc/apache2/sites-available directory and can be enabled by creating symbolic links to the /etc/apache2/sites-enabled directory.

Q

How do I get Apache to listen on multiple ports?

A

Open configure file /etc/httpd/conf/httpd. conf and modify the Listen directive tells the server to accept incoming requests on the specified port. Multiple Listen directives may be used to specify the number of ports to listen.

Q

What is Mod_vhost_alias?

A

mod_vhost_alias. The VirtualDocumentRoot directive allows you to determine where Apache HTTP Server will find your documents based on the value of the server name.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ryan ?
how to use visual traceroute tool

Am using traceroute command to check for the route. i got this tool while surfing. So pls help me out installation and usage of Visual traceroute tool.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.