How Can I Set Up Name-Based Virtual Hosting?
Name-based virtual hosting assigns virtual hosts based on domain names, not IP addresses. With name-based virtual hosting, you can host more than one website (virtual host) on each IP address.
Use the following guidelines to set up name-based virtual hosting:
1. Set up DNS properly:
Forward the domain names of your web sites to the IP address used by your web server. This is commonly done by adding an “A” name entry to the DNS zone file for the website. This is not part of your LiteSpeed Web Server configurations.
2. Set up the virtual hosts in the WebAdmin console:
- Create a virtual host for each web site. (Configuration > Virtual Hosts > Add)
- Create listeners. (Configuration > Listeners > Add)
You can create one listener to listen on all local IP addresses, or you can create multiple listeners with each listener only listening to a specific IP address. Many users will find it simpler to have one listener that is then mapped to different domains, but having multiple listeners can be useful if, for example, you wish to set aside certain server processors for certain sites (see the listener binding section of LSWS's documentation) or conduct special functions on separate ports.
- Assign virtual host mappings.
Go to Configuration > Listeners > View/Edit > Virtual Host Mappings > Edit. In the Virtual Host field, check off all virtual hosts that should be mapped from this listener and specify the corresponding domain name for each virtual host. (In the Domains setting, “your.domain” will match to both www.your.domain
and your.domain
. The leading www.
in a domain name is ignored.)
Note: Since version 4.1, LiteSpeed has supported Server Name Indication (SNI), allowing users to set SSL certificates at the virtual host level. This means that virtual hosts (websites) with different SSL certificates can operate on the the same IP address and port number. Different listeners (and IP-based hosting) are not necessary for secure sites to have unique certificates.
To setup different SSL certificates for different domains, go to LiteSpeed Web Admin Console - > Configuration → Virtual Hosts → Your_domain_virtual_host→ SSL, then set SSL certificates locations.