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 www.company1.com and Www.company2.com'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, www.company1.com.
Planning IP Address: Request a new IP address for the virtual host. (assuming the native IP address is 202.101.2.1)
Www.company1.com 202.101.2.2
2) Let the ISP make the corresponding domain name resolution work.
3) Set the IP alias for the network card:
/sbin/ifconfig eth0:0 202.101.2.2 netmask 255.255.255.0
4) Re-set "/etc/httpd/conf/httpd.conf" to include in the file:
ServerAdmin webmaster@yourdomain.com
Documentroot/home/httpd/www.company1.com
ServerName www.company1.com
Errorlog/var/log/httpd/www.company1.com/error.log
5) Set up the appropriate directory.
Mkdir/home/httpd/www.company1.com
Mkdir/var/log/httpd/www.company1.com/error.log
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.
http://www.bkjia.com/PHPjc/629445.html www.bkjia.com true http://www.bkjia.com/PHPjc/629445.html 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 ...