There are three configuration processes for Apache Virtual Hosts: Ip-based, Port-based, and domain-name-based
- This is done on the Red Hat 5.8 system. First, mount the CD, configure the yum library, and install the development environment.
- Mkdir/mnt/cdrom
- Mount/dev/cdrom/mnt/cdrom
- Vim/etc/yum. reps. d/server. repo
- [Base]
- Name = server
- Baseurl = file: // mnt/cdrom/Server
- Enabled = 1
- Gpgcheck = 0
- Yum groupinstall "Development Libraries"-y)
- Install the httpd package
- Yum list all | grep httpd
- Preparations: Before you begin, determine whether selinux is disabled and cancel the central host.
- 1. Disable selinux
- Setenforce 0
- Check whether it is disabled
- Getenforce
- 2. Cancel the central host
- Vim/etc/httpd/conf/httpd. conf
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S2A06-0.png "/>
3. edit a new configuration file to facilitate management. We will first create an IP-based virtual host.
Vim/etc/httpd/conf. d/virtual. conf
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S21311-1.png "/>
4. Create two directories, create a document under their respective directories, and edit 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S21463-2.png "/> 650) this. width = 650;" border = "0" alt = "" src =" http://www.bkjia.com/uploads/allimg/131228/015S24O9-3.png "/> 650) this. width = 650;" border = "0" alt = "" src =" http://www.bkjia.com/uploads/allimg/131228/015S240R-4.png "/> 5. Add an IP address. this is temporary. After the service is restarted, the IP address is no longer 650.) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S2CA-5.png "/> 6. At this time, the IP address-based solution is ready. Visit the following two websites respectively 650) this. width = 650;" border = "0" alt = "" src =" http://www.bkjia.com/uploads/allimg/131228/015S23964-6.png "/> 650) this. width = 650;" border = "0" alt = "" src =" http://www.bkjia.com/uploads/allimg/131228/015S215R-7.png "/> 7. How to implement access between different ports with the same IP address? Edit the configuration file vim/etc/httpd/conf. d/virtual. conf 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S2KX-8.png "/> Create a directory and edit mkdir/www/B .net vim/etc/B .net/on the home page/
Index. In html 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S2J92-9.png "/> note that listening has not been enabled on port 8080, so enable it here! 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S2ME-10.png "/> restart service: server httpd restart
Access port 8080
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S24G2-11.png "/> 8. Edit the configuration file vim/etc/httpd/conf for the domain name-based VM. d/virtual. conf 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S22203-12.png "/>
- Create a directory and edit the home page file
- To resolve a local domain name in windows, you need to edit the hosts file and change it to the hosts file in windows.) The steps are as follows:
- Drive c -- Windows -- System32 -- Drivers -- etc --> hosts
- If the hosts file is hidden, use the following method to find the hosts
- Tools-Folder Options-View-show hidden files, folders and drive options, hide Extension
- Option --> application, OK. The hosts file appears.
- Add the following content to the hosts file:
- 172.16.50.3 www.d.gov
- 172.16.50.3 www.a.org
- Verification:
- Access by domain name
- Note: If the same Ip address has multiple host names, the same Ip address is used to access the host names.
- At this point, our VM is finished, but you will find that the logs of our VM are all in the same location.
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S22H1-13.png "/> 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S25241-14.png "/> ping it first to see if 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S23463-15.png "/> 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S25a6-16.png "/> 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S24111-17.png "/>
- 9. What should we do if we want different sites to use different logs? It's easy. Just define it.
- Edit configuration file
- Vim/etc/httpd/conf. d/virtual. conf
- After editing, start the following work:
- In the create directory
- Cd/var/log/httpd/
- Mkdir a.org d.org jll.com # log directory
- Service httpd restart # restart the service
- Tail a.org/access_log # view a.org access logs
- Tail jll.com/access_log # view jll.com access logs
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S25a2-18.png "/>
- 10. What should we do if we allow the address 172.16.50.3 to implement user authentication?
- Edit the content in the Add configuration file.
- Vim/etc/httpd/conf. d/virtual. conf
- Restart the service so that access is not allowed.
- 1
- You can access your web page on the VM. You only need to modify/etc/hosts to parse it.
- Vim/etc/hosts
- 172.16.50.3 www.d.gov
- 172.16.50.3 www.a.org
- Access the command by yourself:
- Elinks http://www.d.gov
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S2II-19.png "/> 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S221M-20.png "/> 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S21635-21.png "/>
- 11. We expect the user to provide the account and password before accessing a.org.
- Edit configuration file
- Vim/etc/httpd/conf. d/virtual. conf
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S22330-22.png "/>
- Generate user
- Restart service
- Verify
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S22c7-23.png "/> 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S261Z-24.png "/> 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S25162-25.png "/>
- Supplement: What should I do if I want to browse the http help manual in the form of a website?
- It's easy. You just need to package the help manual.
- Yum install httpd-manual-y
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S24G1-26.png "/>
- Add a small knowledge point
- Location usage
- Edit the main configuration file vim/etc/httpd/conf/httpd. conf
- Restart service
- Verify
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S2O08-27.png "/> 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S24323-28.png "/> How easy! Very practical
This article is from "Li's blog" blog, please be sure to keep this source http://jilili.blog.51cto.com/6617089/1175056