Apache Virtual Host Configuration and wildcard domain name resolution implementation code

Source: Internet
Author: User

Virtual Host Configuration
IP address-based Virtual Host Configuration
Listen 80
DocumentRoot/www/jb51
ServerName www.jb51.net
DocumentRoot/www/jb512
ServerName www.jb512.org
IP-based and multi-port Virtual Host Configuration
Listen 172.20.30.40: 80
Listen 172.000030.40: 8080
Listen 172.20.30.50: 80
Listen 172.20.30.50: 8080
DocumentRoot/www/jb51-80
ServerName www.jb51.net
DocumentRoot/www/jb51-8080
ServerName www.jb51.net
DocumentRoot/www/example2-80
ServerName www.jb51.org
DocumentRoot/www/example2-8080
ServerName www.example2.org
Domain name-based VM configuration on a server with a single IP Address:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *: 80
DocumentRoot/www/jb51
ServerName www.jb51.net
ServerAlias jb51.net. * .jb51.net
# Other directives here
DocumentRoot/www/example2
ServerName www.example2.org
# Other directives here
Configure a domain name-based VM on a server with multiple IP addresses:
Listen 80
# This is the "main" server running on 172.20.30.40
ServerName server.domain.com
DocumentRoot/www/mainserver
# This is the other address
NameVirtualHost 172.20.30.50
DocumentRoot/www/jb51
ServerName www.jb51.net
# Other directives here...
DocumentRoot/www/example2
ServerName www.example2.org
# Other directives here...
Run different sites on different ports:
Configure a domain name-based virtual host on a multi-port server.
Listen 80
Listen 8080.
NameVirtualHost 172.20.30.40: 80
NameVirtualHost 172.000030.40: 8080
ServerName www.jb51.net
DocumentRoot/www/domain-80
ServerName www.jb51.net
DocumentRoot/www/domain-8080
ServerName www.example2.org
DocumentRoot/www/otherdomain-80
ServerName www.example2.org
DocumentRoot/www/otherdomain-8080
Configuration of domain name-based and IP-based Hybrid Virtual Hosts:
Listen 80
NameVirtualHost 172.20.30.40
DocumentRoot/www/jb51
ServerName www.jb51.net
DocumentRoot/www/example2
ServerName www.example2.org
DocumentRoot/www/example3
ServerName www.example3.net
Domain name resolution
Add a VM configuration as follows ):
  
DocumentRoot d:/web/jb51 # absolute path of the website root directory
ServerName www.jb51.net # website Domain Name
ServerAlias * .jb51.net # extensive website Domain Name

APACHE wildcard domain configuration reference

NameVirtualHost 192.168.0.110

<VirtualHost 192.168.0.110: 80>
DocumentRoot "E:/InterRoot/workplace /"
ServerName www.workplace.com
<Directory "E:/InterRoot/workplace/">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow, deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110: 80>
DocumentRoot "E:/InterRoot/busymouse_test /"
ServerName www.test.com
<Directory "E:/InterRoot/busymouse_test/">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow, deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110: 80>
DocumentRoot "E:/InterRoot/iptv_for_browser/auth"
ServerName auth.billing.com
ServerAlias auth.billing.com * .auth.billing.com
# Wildcard domain name resolution
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache. log"
<Directory "E:/InterRoot/iptv_for_browser/auth">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow, deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110: 80>
DocumentRoot "E:/InterRoot/iptv_for_browser/api"
ServerName voiz.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache. log"
<Directory "E:/InterRoot/iptv_for_browser/api">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow, deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110: 80>
DocumentRoot "E:/InterRoot/iptv_for_browser/user"
ServerName user.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache. log"
<Directory "E:/InterRoot/iptv_for_browser/user">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow, deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110: 80>
DocumentRoot "E:/InterRoot/iptv_for_browser/center"
ServerName center.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache. log"
<Directory "E:/InterRoot/iptv_for_browser/center">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow, deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110: 80>
DocumentRoot "E:/InterRoot/iptv_for_browser/img"
ServerName img.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache. log"
<Directory "E:/InterRoot/iptv_for_browser/img">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow, deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110: 80>
DocumentRoot "E:/InterRoot/iptv_for_browser/log"
ServerName log.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache. log"
<Directory "E:/InterRoot/iptv_for_browser/log">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow, deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110: 80>
DocumentRoot "E: \ InterRoot \ billing_new \ front"
ServerName admin.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache. log"
<Directory "E: \ InterRoot \ billing_new \ front">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow, deny
Allow from all
</Directory>
</VirtualHost>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.