Configuration of Apache Virtual host

Source: Internet
Author: User

one, based on IP 1. Assume that the server has an IP address of 192.168.1.10, use Ifconfig to bind 3 Ip:[[email protected] root]# ifconfig eth0:1 on the same network interface eth0 192.168.1.11[[email protected] root]# ifconfig eth0:2 192.168.1.12[[email protected] root]# ifconfig eth0:3 192.168.1.13 2. Modify the Hosts file and add three domain names to each: 192.168.1.11 www.test1.com192.168.1.12 www.test2.com192.168.1.13 www.test3.com 3. Set up the root directory of Web pages, such as the/www directory to establish Test1, Test2, Test3 folder, which respectively store 1.html, 2.html, 3.html/www/test1/1.html/www/test2/2.html/ Www/test3/3.html 4. Include the additional configuration file httpd-vhosts.conf in httpd.conf, and then write the following configuration in httpd-vhosts.conf:<VirtualHost192.168.1.11:80>ServerName www.test1.com documentroot/www/test1/<Directory"/www/test1">Options Indexes followsymlinks allowoverride None Order allow,deny allow from all</Directory></VirtualHost><VirtualHost192.168.1.12:80>ServerName www.test1.com documentroot/www/test2/<Directory"/www/test2">Options Indexes followsymlinks allowoverride None Order allow,deny allow from all</Directory></VirtualHost><VirtualHost192.168.1.13:80>ServerName www.test1.com documentroot/www/test3/<Directory"/www/test3">Options Indexes followsymlinks allowoverride None Order allow,deny allow from all</Directory></VirtualHost>5. Done, test each virtual host, respectively access www.test1.com, www.test2.com, www.test3.com Two, based on host name 1. Set the domain name mapping with one IP, modify hosts:192.168.1.10 www.test1.com192.168.1.10 www.test2.com192.168.1.10 www.test3.com 2. As above, establish the root directory of the Web page hosting the virtual host/www/test1/1.html/www/test2/2.html/www/test3/3.html 3. Include the additional configuration file httpd-vhosts.conf in httpd.conf, and then write the following configuration in httpd-vhosts.conf: In order to use a domain-based virtual host, you must specify the server IP address (and possibly the port) to allow the host to accept the request. Can be configured with the Namevirtualhost directive. If all IP addresses on the server are used, you can use * as Namevirtualhost parameters. Specifying an IP address in the NAMEVIRTUALHOST directive does not cause the server to automatically listen for that IP address.  The IP address set here must correspond to a network interface on the server. The next step is to set up each virtual host that you set up<VirtualHost>Configuration block,<VirtualHost>Parameters are the same as the parameters of the Namevirtualhost directive. Each<VirtualHost>in the definition block, there will be at least one servername instruction to specify which host and a documentroot instruction to indicate where the contents of this host exist in the filesystem. If you add a virtual host to an existing Web server, you must also build a<VirtualHost>defines a block. The contents of servername and DocumentRoot should be consistent with the global, and should be placed at the front of the configuration file, playing the role of the default host. Namevirtualhost *:80<VirtualHost*:80>ServerName * documentroot/www/</VirtualHost><VirtualHost*:80>ServerName www.test1.com documentroot/www/test1/<Directory"/www/test1">Options Indexes followsymlinks allowoverride None Order allow,deny allow from all</Directory></VirtualHost> <VirtualHost*:80>ServerName www.test2.com documentroot/www/test2/<Directory"/www/test2">Options Indexes followsymlinks allowoverride None Order allow,deny allow from all</Directory></VirtualHost> <VirtualHost*:80>ServerName www.test3.com documentroot/www/test3/<Directory"/www/test3">Options Indexes followsymlinks allowoverride None Order allow,deny allow from all</Directory></VirtualHost>4. Done, test each virtual host, respectively access www.test1.com, www.test2.com, www.test3.com three, based on Port 1. Modify the configuration file to change the original Listen 80 to Listen Listen 8080 2. To change the virtual host settings:<VirtualHost192.168.1.10:80>documentroot/var/www/test1/servername www.test1.com</VirtualHost><VirtualHost192.168.1.10:8080>documentroot/var/www/test2 ServerName www.test2.com</VirtualHost>

From: http://www.cnblogs.com/hi-bazinga/archive/2012/04/23/2466605.html

Configuration of Apache Virtual host

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: info-contact@alibabacloud.com 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.