Apache Virtual host configuration and universal domain name resolution implementation code _LINUX

Source: Internet
Author: User
Tags auth
Configuration of the virtual host
Virtual host configuration based on IP address
Listen 80
Documentroot/www/jb51
ServerName www.jb51.net
documentroot/www/jb512
ServerName www.jb512.org
Virtual host configuration based on IP and multi-port
Listen 172.20.30.40:80
Listen 172.20.30.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-based virtual host configuration on a single IP address server:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests to 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
To configure a domain-based virtual host 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
Namevirtualhost 172.20.30.50
Documentroot/www/jb51
ServerName www.jb51.net
# Other directives ...
Documentroot/www/example2
ServerName www.example2.org
# Other directives ...
To run a different site on a different port:
Configure a domain based virtual host on a multiport server.
Listen 80
Listen 8080
Namevirtualhost 172.20.30.40:80
Namevirtualhost 172.20.30.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
Domain-based and IP-based hybrid virtual host configuration:
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
Web site generic Domain name resolution
Add a virtual host configuration (as follows):
  
DocumentRoot d:/web/jb51 # The absolute path of the root directory of the Web site
ServerName www.jb51.net # Website domain name
Serveralias *.jb51.net # web site generic domain name

Apache generic domain name 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
#泛域名解析
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.