Implementation of virtual domain names in Linux-Linux Enterprise Application-Linux server application information. The following is a detailed description. At present, the Linux operating system is very popular, so many friends want to know about the implementation process of virtual domain names in Linux. Next we will discuss it based on the popular RedHat.
1. DNS server settings
We know that the Internet is based on the TCP/IP protocol, and the IP address of the other party must be obtained for communication. This is achieved through the DNS server. Therefore, to implement a virtual domain name, the DNS server should first accept the virtual domain name, that is, map it to the specified IP address. Because we rely on Web servers to differentiate domain names, this IP address should naturally be managed by Web servers.
The bind dns server is bound to the RedHat6.0 operating system. Its Domain Name configuration file is "/etc/named. conf". Generally, the domain configuration file is placed under the "/var/named" directory.
Example 1: configure the named. conf file:
Zone "domain.com "{
Type master;
File "domain.com ";
};
Zone "0.10.10.in-addr. arpa "{
Type master;
File "10.10.0 ";
};
This example shows that the domain configuration file of "domain.com" is "/var/named/domain.com", and the reverse domain configuration file is "/var/named/10.10.0 ". The domain.com file maps the DNS domain name to an IP address.
Example 2. domain.com file Configuration:
@ In soa dns.domain.com. hostmaster.dns.domain.com .(
1998111003 serial
3600 refresh
900 retry
1209600 expire
43200 default_ttl
)
@ In mx 10 dns.domain.com.
@ In ns dns.domain.com.
@ In a 10.10.0.1
Www in a 10.10.0.1
Assume that the domain name to be added is aaa.domain.com. If you want to name www.domain.com, add an alias record to the DNS service. You can write it as follows:
Aaa in cname www.domain.com.
If you need to configure a large number of virtual domain names, the domain.com file is very large and troublesome. We can use the symbol "*" to add the following to the domain.com file:
* In cname www.domain.com.
In this way, all records ending with domain.com that have not been set are transferred to www.domain.com, whether aaa.domain.com or bbb.domain.com. This does not affect existing records. After configuring the DNS server, restart the daemon named:
At present, the Linux operating system is very popular, so many friends want to know about the implementation process of virtual domain names in Linux. Next we will discuss it based on the popular RedHat.
Ii. Apache server configuration
Apache server is currently the most widely used Web server on the Internet. It can maintain very busy sites. RedHat 6.0 is bound with Apache Web Server 1.3. Its configuration file is located in the "/etc/httpd/conf" directory, including httpd. conf, srm. conf, and access. conf. The following describes the configurations related to virtual domain names:
1. Static Configuration
To modify the configuration file httpd. conf:
(1) first set UseCanonicalName to off. It indicates that the ServerName value is provided to the environment variable SERVER_NAME by replacing the server Host: header content.
(2) then add:
NameVirtualHost xxx. xxx is the IP address of the virtual server to be configured. Multiple virtual IP addresses can be configured here, which must be consistent with those configured on the DNS server. (Note: The IP address must be used here, and the domain name cannot be used .)
(3) Add a record for each virtual domain name:
<Virtualhost xxx. xxx>
.....
</Virtualhost>
Xxx. xxx must be the same as the IP address configured for NameVirtualHost. The following configuration parameters can be added between two flags:
The virtual domain name to be added after ServerName, such as aaa.domain.com;
Documentroot: add the path mapped to the local machine, for example, "/home/aaa ";
Redirect: If you map a URL to the remote end, it can be added to the backend. There are two parameters: the first is the relative path of the virtual domain name, and the second is the URL of the remote site;
After ServerAlias, you can add an alias for this domain name. Wildcards can be used, such as * .aaa.domain.com.
The following are two examples:
Example 3: physical path mapped to the local machine:
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.