Implement virtual host service with Apache

xiaoxiao2021-03-06  89

Implementing a virtual host service with Apache 2004-02-07 Click: 1

Implement virtual host service with Apache

What is a virtual host service called virtual host service means that a machine is virtual into multiple web servers. For example, a company wants to provide a host shipping service, providing Web services for other companies. Then it is definitely not to prepare a physical server for each company, but use a strong large server, then use the virtual host to provide a web service of multiple companies, although all Web services It is provided by this server, but the visitor looks like a Web service on a different server. Specifically, we can use the virtual host service to store two different company companies1.com and www.company2.com's homepage on the same host. The visitor only needs to enter the domain name of the company to access the home page it wants. To set up a virtual host service with Apache usually use two options: the virtual host based on the IP address and the name-based virtual host. Here we introduce their implementation methods. So everyone can choose the most appropriate implementation in specific applications. Setting up an IP address-based virtual host service implementation This manner requires an IP alias on the machine, which is to bind multiple IP addresses on a machine's NIC to multiple virtual host services. And use this feature to determine the settings of the IP alias in your Linux kernel, otherwise you must also recompile the kernel. Let's take a service settings with two virtual hosts for reference. 2. Configuration steps assume that we use machines that implement virtual host services, first provide Web services to yourself, now provide virtual host services for new companies companies1.com. Planning an IP address: Apply for a new IP address for a virtual host. (Suppose the native IP address is 202.101.2.1) Company1.com 202.101.2.2 2) Let ISP work accordingly. 3) Set IP alias for the NIC: / sbin / ifconfig eth0: 0 202.101.2.2 Netmask 255.255.255.0 4 Reset "/etc/httpd/conf/httpd.conf", add: serveradmin webmaster@yourDomain.com Documentroot /Home/httpd/www.company1.com servername Company1.com errorlog / var/log/httpd/www.company1.com/error.log 5) Establish a corresponding directory. MKDIR /HOME/HTTPD/www.company1.com mkdir /var/log/httpd/www.company1.com/rror.log 6) Put the corresponding homepage in the corresponding directory. 3. The implementation method of this virtual host has a serious shortage, that is, every time a virtual host must add an IP address. Since IP address space is already very tight, it is usually unable to achieve so many IP addresses. And in a sense, this is also a waste of IP address. Setting up the name-based virtual host service based on name-based virtual host services is a solution suitable for use. Because it doesn't need more IP addresses, and it is easy to configure, no special hardware and software support is required. Most modern browsers support this implementation method of this virtual host. Of course, this means that some early client browsers may not support this virtual host implementation method. It is for the above reasons, we have no reason not to use the name-based virtual host service using an IP address.

转载请注明原文地址:https://www.9cbs.com/read-103831.html

New Post(0)