Use the same IP for different host names using the httpd virtual host

Source: Internet
Author: User

Background introduction

Traditional HTTPD service can only provide service to one host, sometimes there will be the same IP address for multiple hostnames to provide service requirements, the following is to introduce the specific steps, topology diagram as follows:

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/86/21/wkiom1e1ce3qr4weaabo3pqawf0792.png-wh_500x0-wm_3-wmp_4-s_1201348588.png "title = "1.png" style= "Float:none;" alt= "Wkiom1e1ce3qr4weaabo3pqawf0792.png-wh_50"/>

Operation Steps

1. After installing the HTTPD service, start the httpd service, the boot will be a bit slow, can be prompted to see is because the host name resolution address is not found

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s5.51cto.com/wyfs02/m01/86/20/wkiol1e1ce7txoomaaat3fsmuyc526.png-wh_500x0-wm_3-wmp_4-s_4160213328.png "title = "2.png" style= "Float:none;" alt= "Wkiol1e1ce7txoomaaat3fsmuyc526.png-wh_50"/>

Add the local IP address under 2./etc/httpd/conf/httpd.conf so that the local address is used directly

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s5.51cto.com/wyfs02/m01/86/20/wkiol1e1ce6jdmlaaaberztseny189.png-wh_500x0-wm_3-wmp_4-s_1344794461.png "title = "3.png" style= "Float:none;" alt= "Wkiol1e1ce6jdmlaaaberztseny189.png-wh_50"/>

3. Create a index.html file in the/var/www/html directory and use the browser test to ensure that the service is healthy

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s5.51cto.com/wyfs02/m02/86/21/wkiom1e1ce6txfjlaaat_womae4349.png-wh_500x0-wm_3-wmp_4-s_646054409.png "title= "4.png" style= "Float:none;" alt= "Wkiom1e1ce6txfjlaaat_womae4349.png-wh_50"/>

4. The above method 172.16.10.10/24 this IP can only provide services for a host, if you want to allow multiple hosts to use a single IP in the configuration file to enable httpd in the virtual host, you need to note that the virtual Host service and httpd default service cannot exist simultaneously. Unregisters the default root file path within the profile/etc/httpd/conf/httpd.conf file, which is why the Web page's files are placed in the/var/www/html directory

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s5.51cto.com/wyfs02/m02/86/20/wkiol1e1ce6i1sjsaaast9pj9fe452.png-wh_500x0-wm_3-wmp_4-s_3023180183.png "title = "5.png" style= "Float:none;" alt= "Wkiol1e1ce6i1sjsaaast9pj9fe452.png-wh_50"/>

5. Cancel the logout of the namevirtualhost, and let him listen to 80 ports of all addresses.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s1.51cto.com/wyfs02/m00/86/21/wkiom1e1ce_b_siwaaaqv77hopa312.png-wh_500x0-wm_3-wmp_4-s_1747006847.png "title = "6.png" style= "Float:none;" alt= "Wkiom1e1ce_b_siwaaaqv77hopa312.png-wh_50"/>

6. Add a virtual machine container for each host and indicate the hostname and root document path, complete the configuration file and use the Httpd-t check

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/86/20/wkiol1e1ce_rgzdnaaanvjnjvlm778.png-wh_500x0-wm_3-wmp_4-s_1341035221.png "title = "7.png" style= "Float:none;" alt= "Wkiol1e1ce_rgzdnaaanvjnjvlm778.png-wh_50"/>

7. Create the appropriate directory under the specified document path, and create a index.html file in each directory, rereading the httpd configuration file

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m00/86/21/wkiom1e1ce_tsxodaaaryytfrlk144.png-wh_500x0-wm_3-wmp_4-s_1184493425.png "title = "8.png" style= "Float:none;" alt= "Wkiom1e1ce_tsxodaaaryytfrlk144.png-wh_50"/>

8. Modify the host file for client side hosts

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/86/21/wkiom1e1ce_cpiotaaaafhzt1um382.png-wh_500x0-wm_3-wmp_4-s_4281175034.png "title = "9.png" style= "Float:none;" alt= "Wkiom1e1ce_cpiotaaaafhzt1um382.png-wh_50"/>

9. Enter the address in the client browser, verify the result, and the operation is complete.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s1.51cto.com/wyfs02/m00/86/20/wkiol1e1cfdgrz8iaaaxghzwhzw855.png-wh_500x0-wm_3-wmp_4-s_2354174504.png "title = "10.png" style= "Float:none;" alt= "Wkiol1e1cfdgrz8iaaaxghzwhzw855.png-wh_50"/>

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/86/20/wKioL1e1cfCBUTIPAAAvH7HTKhQ021.png-wh_500x0-wm_3 -wmp_4-s_2988958608.png "title=" 11.png "style=" Float:none; alt= "Wkiol1e1cfcbutipaaavh7htkhq021.png-wh_50"/>



This article from "Rabbit-like rabbit sen Broken" blog, please be sure to keep this source http://arkling.blog.51cto.com/2844506/1840027

Use the same IP for different host names using the httpd 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.