Several Apache configurations

Source: Internet
Author: User

There are three configuration processes for Apache Virtual Hosts: Ip-based, Port-based, and domain-name-based

 
 
  1. This is done on the Red Hat 5.8 system. First, mount the CD, configure the yum library, and install the development environment.
  2. Mkdir/mnt/cdrom
  3. Mount/dev/cdrom/mnt/cdrom
  4. Vim/etc/yum. reps. d/server. repo
  5. [Base]
  6. Name = server
  7. Baseurl = file: // mnt/cdrom/Server
  8. Enabled = 1
  9. Gpgcheck = 0
  10. Yum groupinstall "Development Libraries"-y)
  11. Install the httpd package
  12. Yum list all | grep httpd
  13. Preparations: Before you begin, determine whether selinux is disabled and cancel the central host.
  14. 1. Disable selinux
  15. Setenforce 0
  16. Check whether it is disabled
  17. Getenforce
  18. 2. Cancel the central host
  19. 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 "/>
 
 
  1. Create a directory and edit the home page file
  2. 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:
  3. Drive c -- Windows -- System32 -- Drivers -- etc --> hosts
  4. If the hosts file is hidden, use the following method to find the hosts
  5. Tools-Folder Options-View-show hidden files, folders and drive options, hide Extension
  6. Option --> application, OK. The hosts file appears.
  7. Add the following content to the hosts file:
  8. 172.16.50.3 www.d.gov
  9. 172.16.50.3 www.a.org
  10. Verification:
  11. Access by domain name
  12. Note: If the same Ip address has multiple host names, the same Ip address is used to access the host names.
  13. 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 "/>
 
 
  1. 9. What should we do if we want different sites to use different logs? It's easy. Just define it.
  2. Edit configuration file
  3. Vim/etc/httpd/conf. d/virtual. conf
  4. After editing, start the following work:
  5. In the create directory
  6. Cd/var/log/httpd/
  7. Mkdir a.org d.org jll.com # log directory
  8. Service httpd restart # restart the service
  9. Tail a.org/access_log # view a.org access logs
  10. 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 "/>
 
 
  1. 10. What should we do if we allow the address 172.16.50.3 to implement user authentication?
  2. Edit the content in the Add configuration file.
  3. Vim/etc/httpd/conf. d/virtual. conf
  4. Restart the service so that access is not allowed.
  5. 1
  6. You can access your web page on the VM. You only need to modify/etc/hosts to parse it.
  7. Vim/etc/hosts
  8. 172.16.50.3 www.d.gov
  9. 172.16.50.3 www.a.org
  10. Access the command by yourself:
  11. 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 "/>
 
 
  1. 11. We expect the user to provide the account and password before accessing a.org.
  2. Edit configuration file
  3. 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 "/>
 
 
  1. Generate user
  2. Restart service
  3. 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 "/>
 
 
  1. Supplement: What should I do if I want to browse the http help manual in the form of a website?
  2. It's easy. You just need to package the help manual.
  3. Yum install httpd-manual-y
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/015S24G1-26.png "/>
 
 
  1. Add a small knowledge point
  2. Location usage
  3. Edit the main configuration file vim/etc/httpd/conf/httpd. conf
  4. Restart service
  5. 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

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.