Configuration of Apache virtual directory and multi-port multiple host name

Source: Internet
Author: User

1. Virtual directory
Each Internet service can be published from multiple directories, a virtual server can have one host directory and any number of other publishing directories, and other publishing directories are called virtual directories.
Specifies the customer URL address that the service submits to the customer as a directory tree for the entire publishing catalog set. The host directory is the root of the virtual directory tree, and the actual subdirectory of the virtual directory is also available to the customer.
2. Port-based virtual host
Port-based virtual hosts are typically used only for the same Web site, where the site name and IP address are often the same, but different TCP ports provide access to different Web content. When you access a Web server that is not a 80 port in a browser, you need to explicitly indicate the port number of the server.
3. Domain-based virtual host
You first need to provide the domain name of the virtual Web site to the DNS server so that when you access any of these virtual Web sites, you end up with the same IP address-the IP address of the server that actually supports all virtual Web sites.

The following three small experiments are introduced respectively.
1. Virtual directory
First install the httpd in Linux, you can use RPM-QC httpd to view the configuration file about httpd after installation.

Edit the master configuration file



Go to the/ETC/HTTPD/CONF.D directory and you can see that the basic is the. conf end of the configuration file

Create a new configuration file named Vdir.conf and enter the following:


Go to the/OPT directory to create a new test folder

Restart the httpd service, turn off firewall and security features

Host browser Access test, the Linux server that provides the service IP address is 192.168.100.10/24

Virtual directory to enable authentication, edit the virtual directory configuration file, vim/etc/httpd/conf.d/vdir.conf

New virtual Directory Access user Zhangsan

Host Browser Access test

Enter a set user name and password to log in to see the content

2. Port-based virtual host
Also go to the/ETC/HTTPD/CONF.D directory, create a new vport.conf configuration file, enter the following:


Go to the/OPT directory and create a new Xxy1,xxy2 folder, corresponding to the home page file

Edit Master profile, add listen 8080 port


Restart HTTPD Service

Host browser access test, because the default is 80 port, so the IP address plus 80 port does not display, 8080 port can also be accessed normally


3. Domain-based virtual host
Go to the/ETC/HTTPD/CONF.D directory, create a new vhost.conf configuration file, and enter the following:


/opt/xxy1,/opt/xxy2 in the previous experiment has been created to complete
Now build DNS service for Domain name resolution

Edit the master configuration file, modify the listening address, and set all the network segments to be able to parse


Edit the zone configuration file and enter the following in the forward parsing area


Go to the/var/named directory, copy the Zone Data profile template, make sure to keep the original file attributes with Cp-p, and then edit it.


Another www.xxy2.com domain name resolves the IP address after the same as www.xxy1.com, you can directly copy the www.xxy1.com zone data configuration file

Turn on the domain name resolution service to restart the HTTPD service if the vport.conf of the previous experiment is not deleted. Restart httpd service will pop up a warning, but does not affect the browser test, will vport.conf this file deletion is not.

Host Browser Access test


This experiment is done

Configuration of Apache virtual directory and multi-port multiple host name

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.