Use Apache to implement virtual host services

Source: Internet
Author: User
Tags mkdir web services
What is a VM service?
A virtual host service virtualizes a machine into multiple WEB servers. For example, a company wants to provide host hosting services, which provides WEB services for other enterprises. Therefore, it certainly does not prepare a physical server for each enterprise, but uses a large server with powerful functions and then uses a virtual host, it provides WEB services for multiple enterprises. Although all WEB services are provided by this server, visitors can see that they have the same WEB services on different servers.
Specifically, we can use the VM service to store the home pages of and of two different companies on the same host. Visitors only need to enter the domain name of the company to access the homepage content they want.
You can use Apache to set up the VM service in two ways: IP address-based virtual host and name-based virtual host. The following describes their implementation methods. So that you can select the most appropriate implementation method in specific applications.
Set and implement IP address-based VM service


In this way, you need to set the IP alias on the machine, that is, bind multiple
IP addresses are used to serve multiple VM instances. To use this function, make sure that the IP alias settings must be supported in your Linux kernel. Otherwise, you must re-compile the kernel.
The following is a service setting with two virtual hosts for your reference.
2. Configuration steps
Assume that the machine we use to implement the VM service already provides the WEB service for ourselves. Now we will provide the VM service for, a new company.
Planned IP address: apply for a new IP address for the VM. (Assume that the local IP address is

2) enable the ISP to resolve the domain name.
3) set an IP alias for the NIC:
/Sbin/ifconfig eth0: 0 netmask
4) reset "/etc/httpd/conf/httpd. conf" and add the following to the file:


5) create a directory.

6) store the corresponding homepage content in the corresponding directory.
3. Unfavorable factors
There is a serious deficiency in the implementation of such virtual hosts, that is, each time a virtual host is added, an IP address must be added. Because the IP address space is very tight, it is usually impossible to obtain so many IP addresses. In a sense, this is also a waste of IP addresses.
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.