Apache Configure sites and virtual directories

Source: Internet
Author: User

One, single site configuration:
In Apache, configuring a site is the most basic configuration, where I just want to configure a most basic web site, so the configuration is very simple, the configuration is as follows:
######## #主站点配置 ###########
#侦听端口
Listen 80
#站点域名
ServerName www.test.cn
#站点文件主目录
Documentroot/data/www/test
#该站点限制
<directory/>
AllowOverride None
Order Deny,allow
Deny from all
Satisfy All
</Directory> two, single-site virtual directory configuration:
For different pages specified by the DocumentRoot, we can do this by means of aliases, which are implemented in the same way as virtual directories in IIS, with the following configuration:
######## #主站点配置 ###########
#侦听端口
Listen 80
#站点域名
ServerName www.test.cn
#站点文件主目录
Documentroot/data/www/test
#该站点限制
<directory/>
AllowOverride None
Order Deny,allow
Deny from all
Satisfy All
</Directory>
######## #别名 (virtual directory) configuration ###########
#定义虚拟目录名称 and specify a specific directory
alias/alias1//DATA/WWW/ALIAS1
alias/alias2//DATA/WWW/ALIAS2 Three, multi-site configuration:
An Apache server if you run a small site, it is not possible to run only one station, you may need to configure a number of sites on this server, the implementation of the configuration is also relatively simple, the implementation of the following methods:
######## #多站点配置1 (This approach applies to a single server with only one IP address, multiple domain names are resolved to that IP address at the same time, and only one 80 port is listening) ###########
Namevirtualhost xxx.xxx.xxx.xxx
#定义主机1
<virtualhost xxx.xxx.xxx.xxx>
Documentroot/data/www/test1
ServerName www.test1.cn
</Virtualhost>
#定义主机2
<virtualhost xxx.xxx.xxx.xxx>
Documentroot/data/www/test2
ServerName www.test2.cn
</Virtualhost>
#定义主机3
<virtualhost xxx.xxx.xxx.xxx>
Documentroot/data/www/test3
ServerName www.test3.cn
</Virtualhost> ######## #多站点配置2 (This approach applies to a single server configured with multiple IPs, multi-domain different parsing to different ip###########
#定义主机1 (the domain name must be resolved to IP1)
<virtualhost 192.168.0.10>
Documentroot/data/www/test1
ServerName www.test1.cn
</VirtualHost>
#定义主机2 (the domain name must be resolved to IP2)
<virtualhost 192.168.0.20>
Documentroot/data/www/test2
ServerName www.test2.cn
</VirtualHost>
#定义主机3 (the domain name must be resolved to IP3)
<virtualhost 192.168.0.30>
Documentroot/data/www/test3
ServerName www.test3.cn
</VirtualHost> four, multi-site virtual directory configuration:
Because there are two ways to configure multiple sites, this article uses the first most commonly used single IP multi-domain configuration, the configuration is as follows:
Namevirtualhost xxx.xxx.xxx.xxx
#定义主机1
<virtualhost xxx.xxx.xxx.xxx>
Documentroot/data/www/test1
ServerName www.test1.cn
alias/alias1//DATA/WWW/ALIAS1
</Virtualhost>
#定义主机2
<virtualhost xxx.xxx.xxx.xxx>
Documentroot/data/www/test2
ServerName www.test2.cn
alias/alias2//DATA/WWW/ALIAS2
</Virtualhost>
#定义主机3
<virtualhost xxx.xxx.xxx.xxx>
Documentroot/data/www/test3
ServerName www.test3.cn
alias/alias3//DATA/WWW/ALIAS3
</Virtualhost>

Apache Configure sites and virtual directories

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.