Apache Build virtual web Host
Knowledge section
1. Virtual Web host refers to running multiple Web sites on the same server, one of which is common to one server. Running a Web site from a virtual web host can save hardware resources and reduce operational costs.
2. Apache virtual Web host is divided into three kinds
Virtual hosts based on different domain names
Virtual hosts based on different IP addresses
and virtual hosts based on different port numbers
Work is often based on a different domain name of the virtual host, the other two virtual host is not a lot of running.
Operation section
Idea: The first to do a domain-based virtual host, we need to set up two Web sites corresponding DNS resolution support
First: Get ready to install Apache services and DNS services on a single Linux server.
1, install the DNS service is installed bind-9
and Bind-chrootPackage.
2, configure the DNS master file; vim/var/named/chroot/etc/named.conf file
3, configuration benet area data file; vim/var/named/chroot/var/named/benet.com.zone
4, configuration ACCP area data file; vim/var/named/chroot/var/named/accp.com.zone
5. Prepare the required pages for two
6, edit the virtual host configuration file; vim/usr/local/httpd/conf/extra/http-vhosts.conf
Locate the underlined position and make the following changes
Until you find it, modify
7, modify the Apache master configuration file; vim/usr/local/httpd/conf/httpd.conf
Find the following location and delete the "#" before the Include
8. Restart the httpd and named services. (Configure address, turn off firewall)
9, open a Win7, as the Web client, configure the address 192.168.1.200, and then access www.benet.com and www.accp.com
Idea: The second type of virtual host based on different IP addresses. First we need to configure an IP address for the Web server and then change the virtual host configuration file. (DNS is useless at this time)
1. Add IP Address
2. Change the virtual host configuration file httpd-vhosts.conf
3. Restart HTTPD Service
4, landing on the Win7 192.168.1.1 and 192.168.1.2
Idea: Third, a virtual host based on a different port. The Benet remains the same, and we modify the httpd-vhosts.conf and the main provisioning file. (The main configuration file by default listening to 80 port, that is, httpd default port, now to use a different port, you need to set up in the main file to listen to a new port)
1. Modify the virtual host configuration file httpd-vhosts.conf
2, modify the main file httpd.conf
3, landing on the Win7 http://www.benet.com:80 and http://www.accp.com:801. Note that the input URL is preceded by "HTTP//", otherwise the port can not be logged
Apache Build virtual web Host