Apache 2.4 Virtual Host Configuration

Source: Internet
Author: User

A virtual host is one that runs multiple websites (for example company1.example.com , and) on a single machine company2.example.com . A virtual host can be "IP-based", that is, one site per IP, or "Based on name", that is, multiple sites per IP. The fact that these sites run on the same physical server is not clearly disclosed to the end user. -This is the official website explanation.


Configure the Apache virtual host. (Httpd-vhosts.conf--apache virtual Host configuration file)

Name-based virtual hosts (multiple sites per IP)

<virtualhost *:80>    # This first-listed virtual host was also the default for *:80 ServerName www.example.com<    C8/>serveralias example.com     documentroot/www/domain</virtualhost><virtualhost *:80>    ServerName other.example.com    documentroot/www/otherdomain</virtualhost>

noun explanation:

VirtualHost: Refers to the ip/domain name of the virtual host, *:80 represents all IPs representing all 80 ports

ServerName: Virtual host Name

Serveralias: Virtual host alias, host alias can be multiple support wildcard characters

Serveralias Example . *. Example . com

DocumentRoot: Site Directory



IP-based virtual hosts (one site per IP)

Listen 172.20.30.40:80<virtualhost 172.20.30.40:80>    ServerAdmin [email protected]    documentroot/www/ VHOSTS/WWW1    ServerName www1.example.com    errorlog/www/logs/www1/error_log    customlog/www/logs/www1/ Access_log combined</virtualhost> <pre name= "code" class= "plain" >listen 172.20.30.50:80<virtualhost 172.20.30.50:80>    ServerAdmin [email protected]    DOCUMENTROOT/WWW/VHOSTS/WWW2    ServerName www2.example.org    errorlog/www/logs/www2/error_log    customlog/www/logs/www2/access_log combined</ Virtualhost>

noun explanation :

<pre name= "code" class= "plain" >serveradmin  Webmaster mailbox <pre name= "code" class= "plain" ><pre name= "code "Class=" plain ">errorlog  error log <pre name=" code "class=" plain "><pre name=" code "class=" plain "> Customlog  Access Log


Enable Apache Virtual Host feature (httpd.conf)

Search the Virtual hoststo get rid of the conf/extra/httpd-vhosts.conf in front of #Include

# Virtual Hosts#include conf/extra/httpd-vhosts.conf

Restart Apache Service


Apache 2.4 Virtual Host Configuration

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.