due to the HTTPD service core host and virtual host, two ways of fire and fire, so, to set up a virtual host, the first need to shut down the core host, that is, comments httpd in the main file
Vim/etc/httpd/conf/httpd.conf
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/70/F5/wKioL1XCKbjx9Ml0AAA-Y_onJL4485.jpg "style=" float: none; "title=" 1.png "alt=" Wkiol1xckbjx9ml0aaa-y_onjl4485.jpg "/>
The virtual host has three modes of operation:
based on Ip
based on Port
based on Host
based on Ip
Two virtual hosts that implement the following requirements
IP used is 192.168.56.169 (IP forvirtual machine ),192.168.56.170(need to add IP yourself )
Global Listening Listen 80
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/70/F5/wKioL1XCKbiBDQChAAEVCztnK80600.jpg "style=" float: none; "title=" 2.png "alt=" Wkiol1xckbibdqchaaevcztnk80600.jpg "/>
Add IP
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/70/F9/wKiom1XCJ8GANsnYAACB3niAwN8056.jpg "style=" float: none; "title=" 4.png "alt=" Wkiom1xcj8gansnyaacb3niawn8056.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/70/F5/wKioL1XCKbqg6zK5AAMCdMYjEb0125.jpg "style=" float: none; "title=" 5.png "alt=" Wkiol1xckbqg6zk5aamcdmyjeb0125.jpg "/>
Physical machine Ping These two IP
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/F5/wKioL1XCKbvBQIpvAAE9fzfJYp8036.jpg "style=" float: none; "title=" 6.png "alt=" Wkiol1xckbvbqipvaae9fzfjyp8036.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/70/F9/wKiom1XCJ8LRlOHGAAEgVC0BHhg646.jpg "style=" float: none; "title=" 7.png "alt=" Wkiom1xcj8lrlohgaaegvc0bhhg646.jpg "/>
Modifying a configuration file
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/F9/wKiom1XCJ8LCgExHAADoXccwrNg058.jpg "style=" float: none; "title=" 8.png "alt=" Wkiom1xcj8lcgexhaadoxccwrng058.jpg "/>
Create directories and content as follows
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/F5/wKioL1XCKbvi65-nAADZlJJgT5w171.jpg "style=" float: none; "title=" 9.png "alt=" Wkiol1xckbvi65-naadzljjgt5w171.jpg "/>
Restart the httpd service and find the following error
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/70/F6/wKioL1XCKbyyIk6mAACnrA-QDdc576.jpg "style=" float: none; "title=" 10.png "alt=" Wkiol1xckbyyik6maacnra-qddc576.jpg "/>
Modify DocumentRoot to Absolute address
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/F9/wKiom1XCJ8ODHALfAAFLPvGB444349.jpg "style=" float: none; "title=" 11.png "alt=" Wkiom1xcj8odhalfaaflpvgb444349.jpg "/>
Restart Service
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/70/F6/wKioL1XCKbyjOoI5AAC6P7bL8PY995.jpg "style=" float: none; "title=" 12.png "alt=" Wkiol1xckbyjooi5aac6p7bl8py995.jpg "/>
Test
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/70/F9/wKiom1XCJ8Pw7jNmAAB8E0vbIJY227.jpg "style=" float: none; "title=" 13.png "alt=" Wkiom1xcj8pw7jnmaab8e0vbijy227.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/70/F9/wKiom1XCJ8TSVTycAAB2r6uMq9I614.jpg "style=" float: none; "title=" 14.png "alt=" Wkiom1xcj8tsvtycaab2r6umq9i614.jpg "/>
Port-based
The following requirements to establish two different ports of the same IP virtual host, this method can save IP resources.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/70/F6/wKioL1XCKb3R6hh1AAEhSLpSWKE095.jpg "style=" float: none; "title=" 15.png "alt=" Wkiol1xckb3r6hh1aaehslpswke095.jpg "/>
In the configuration file, add 8080 port, default is 80
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/70/F6/wKioL1XCKb2z-1aiAABiiBI1Agw839.jpg "style=" float: none; "title=" 16.png "alt=" Wkiol1xckb2z-1aiaabiibi1agw839.jpg "/>
Modify Virtual Host Settings
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/70/F9/wKiom1XCJ8SwKIhWAADc-2RveVE400.jpg "style=" float: none; "title=" 17.png "alt=" Wkiom1xcj8swkihwaadc-2rveve400.jpg "/>
Restart Service
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/F6/wKioL1XCKb6wZYM7AACdXIEBA6c111.jpg "style=" float: none; "title=" 18.png "alt=" Wkiol1xckb6wzym7aacdxieba6c111.jpg "/>
Test
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/70/F9/wKiom1XCJ8WRgvThAAB8dp2xNIY890.jpg "style=" float: none; "title=" 19.png "alt=" Wkiom1xcj8wrgvthaab8dp2xniy890.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/F9/wKiom1XCJ8by5MSbAACKacPieBw286.jpg "style=" float: none; "title=" 20.png "alt=" Wkiom1xcj8by5msbaackacpiebw286.jpg "/>
Domain-based virtual hosting (pending update)
done!
Adelazhu
This article from "Adela" blog, declined reprint!
"Apache Learning" IP-based, Port-based virtual host in Linux