Using Apache to implement virtual hosting service _php Tutorial

Source: Internet
Author: User
Tags hosting
What is a virtual hosting service
The so-called virtual hosting service refers to the virtual machine into multiple Web servers. For example, a company wants to engage in providing colocation services, which provide Web services to other businesses. Then it certainly is not for each enterprise to prepare a physical server, but with a powerful large server, and then the form of virtual host, to provide multiple enterprise Web services, although all Web services are provided by this server, But it makes it look like you're getting Web services on a different server.
Specifically, we can use the virtual hosting service to store two different company and's home page content on the same host. Visitors can simply enter the company's domain name to access the page content it wants.
Using Apache to set up a virtual hosting service can usually be implemented in two ways: IP address-based virtual host and name-based virtual host, let's describe how to implement them separately. So that you can choose the most suitable method of implementation in the specific application.
Set up a virtual host service that implements IP address-based

Implementation Prerequisites
This way, you need to set the IP alias on the machine, that is, the network card of a machine is bound to multiple
IP address to serve multiple virtual hosts. And to use this feature, you also have to make sure that the IP alias settings must be supported in your Linux kernel, otherwise you will have to recompile the kernel.
Here is a service setting with two virtual hosts for reference.
2. Configuration steps
Assuming that the machine we used to implement the virtual hosting service has already provided itself with Web services, it will now provide virtual hosting services for a new company,
Planning IP Address: Request a new IP address for the virtual host. (assuming the native IP address is

2) Let the ISP make the corresponding domain name resolution work.
3) Set the IP alias for the network card:
/sbin/ifconfig eth0:0 netmask
4) Re-set "/etc/httpd/conf/httpd.conf" to include in the file:


5) Set up the appropriate directory.
6) store the corresponding page content in the appropriate directory.
3. Adverse factors
This virtual host implementation method has a serious disadvantage, that is, each additional virtual host, you must add an IP address. Because the IP address space is already very tense, so many IP addresses are usually not available. And in a sense, it's also a waste of IP addresses. true techarticle What is a virtual hosting service? The so-called virtual hosting service means that a machine is virtualized into multiple Web servers. For example, a company wants to be engaged in providing colocation services ...

  • Related Article

    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.

    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.