If your website visit is not very large, very lightweight, then put on a server alone is a waste of the server, electricity will be a lot, so with the virtual host this problem can be solved, virtual host can implement a host to maintain multiple sites.
There are three implementation scenarios:
IP-based: Prepare at least one IP address for each virtual host;
Based on port: prepare at least one dedicated port for each virtual host; seldom used in practice;
Based on hostname: Prepare at least one dedicated hostname for each virtual host;
Can be mixed using any of the above three ways;
Note: The general virtual host is mixed with the central host, so, to use the virtual host, first disable the central host;
Disable Central host: Comment DocumentRoot
Each virtual host has a dedicated configuration:
<virtualhost "Ip:port" >
Severname
DocumentRoot ""
</VirtualHost>
Serveralias: Alias of the virtual host;
Errorlog
Customlog
<directory "" >
</Directory>
Experiment:
1. IP-based virtual hosts:
Disable Central host: Comment DocumentRoot
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/6B/wKioL1X9YDOxKoQ5AACJV_mmOCQ230.jpg "style=" float: none; "title=" 22.png "alt=" Wkiol1x9ydoxkoq5aacjv_mmocq230.jpg "/>
To change the configuration file:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/6D/wKiom1X9XfiSYQnQAAB1PVcTqIY894.jpg "style=" float: none; "title=" 23.png "alt=" Wkiom1x9xfisyqnqaab1pvctqiy894.jpg "/>
To create a page file storage directory:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/6B/wKioL1X9YDSAsD4uAAD6ssZcsHM678.jpg "style=" float: none; "title=" 24.png "alt=" Wkiol1x9ydsasd4uaad6sszcshm678.jpg "/>
To create a paging file:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/6D/wKiom1X9XfmAG1FYAABF7d3Q2Ac386.jpg "style=" float: none; "title=" 25.png "alt=" Wkiom1x9xfmag1fyaabf7d3q2ac386.jpg "/>
2. Port-based virtual hosts:
httpd.conf file:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/6B/wKioL1X9YdfBP_EDAAB1JI664dE012.jpg "title=" 26.png "alt=" Wkiol1x9ydfbp_edaab1ji664de012.jpg "/>
To create a paging file:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/6E/wKiom1X9XwOy0YhZAABEzI_Fu3Q309.jpg "style=" float: none; "title=" 27.png "alt=" Wkiom1x9xwoy0yhzaabezi_fu3q309.jpg "/>
3. Host name-based virtual host:
To modify a configuration file:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/6C/wKioL1X9Y3_hi_4mAAAsnIauJXs956.jpg "style=" float: none; "title=" 28.png "alt=" Wkiol1x9y3_hi_4maaasniaujxs956.jpg "/>
Note that the upper and lower IP addresses should correspond
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/6E/wKiom1X9YUSzgSLkAAC4NiQqGlI946.jpg "style=" float: none; "title=" 29.png "alt=" Wkiom1x9yuszgslkaac4niqqgli946.jpg "/>
Overloaded httpd Service Test
To modify the/etc/hosts file:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/6C/wKioL1X9ZYGR8AP9AAAd_yOXl_Q459.jpg "style=" float: none; "title=" 31.png "alt=" Wkiol1x9zygr8ap9aaad_yoxl_q459.jpg "/>
Test found success:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/6E/wKiom1X9Y0bQaQCTAAA_9aRJlq4068.jpg "style=" float: none; "title=" 32.png "alt=" Wkiom1x9y0bqaqctaaa_9arjlq4068.jpg "/>
For virtual host custom log file storage location:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/6C/wKioL1X9Z3rBODhBAAD7Xbq7cx4784.jpg "style=" float: none; "title=" 33.png "alt=" Wkiol1x9z3rbodhbaad7xbq7cx4784.jpg "/>
After restarting the service, it was discovered that the virtual host's respective log files were generated:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/6E/wKiom1X9ZT_RjezpAABEYWueoqc634.jpg "style=" float: none; "title=" 34.png "alt=" Wkiom1x9zt_rjezpaabeywueoqc634.jpg "/>
Configure the built-in status page
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/6C/wKioL1X9aGGA-rvmAABBk6oIjrE096.jpg "style=" float: none; "title=" 35.png "alt=" Wkiol1x9agga-rvmaabbk6oijre096.jpg "/>
Discovery Output Host Information: (This approach is unsafe)
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/6C/wKioL1X9aGLwhBcNAAMsD8LafNg068.jpg "style=" float: none; "title=" 36.png "alt=" Wkiol1x9aglwhbcnaamsd8lafng068.jpg "/>
This article is from the "After Tomorrow" blog, please be sure to keep this source http://leeyan.blog.51cto.com/8379003/1696391
httpd virtual Host and HTTPS implementations