Apache configuration of various virtual hosts

Source: Internet
Author: User
Apache configuration of various virtual host practices-Linux Enterprise Application-Linux server application information, the following is a detailed description. 1. practice environment:
Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
Server version: Apache/1.3.34 (Unix)
Server built: Sep 26 2006 15:06:28

2. Domain Name-based VM:
Vi httpd. conf
......
......
BindAddress *
Indicates that all addresses can be used to listen to VM requests.
NameVirtualHost *: 80
Use a domain name-based VM

ServerName mail. OK .com
DocumentRoot/var/www/html
ScriptAlias/cgi-bin/"/opt/apache/cgi-bin /"


ServerName mail.test.com
DocumentRoot/opt/apache/html
ScriptAlias/cgi-bin/"/opt/apache/cgi-bin /"

......
......

Summary: this domain name-based configuration is suitable when the server has only one public ip address. Each virtual host must be set Command block. You can add commands other than ServerType, Startservers, MaxSpareserver, MinSpareserver, MaxRequestsPerchild, BindAddress, Lister, PidFile, TypeConfig, ServerRoot, and NameVirtualHost. This method must depend on DNS resolution.

3. IP address-based VM

Vi httpd. conf
......
......
BindAddress *
Indicates that all addresses can be used to listen to VM requests.
# NameVirtualHost *: 80
Use a domain name-based VM

ServerName mail. OK .com
DocumentRoot/var/www/html
ScriptAlias/cgi-bin/"/opt/apache/cgi-bin /"


ServerName mail.test.com
DocumentRoot/opt/apache/html
ScriptAlias/cgi-bin/"/opt/apache/cgi-bin /"


......
......

4. Port-based VM

Vi httpd. conf
......
......
BindAddress *
Indicates that all addresses can be used to listen to VM requests.
Listen 8080.
Let apache listen to port 8080. Here the ip: port mode is used.
# NameVirtualHost 192.168.0.246: 8080
Use a virtual host based on domain name. If you want to use the Domain Name: port mode, open it here.

ServerName mail. OK .com
DocumentRoot/var/www/html
ScriptAlias/cgi-bin/"/opt/apache/cgi-bin /"


ServerName mail.test.com
DocumentRoot/opt/apache/html
ScriptAlias/cgi-bin/"/opt/apache/cgi-bin /"


......
......
Related Article

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.