Apache base with different types of virtual hosts

Source: Internet
Author: User
Tags hosting

Apache's virtual hosting is divided into three types:

IP-based virtual host

Port-based virtual host

Domain-based virtual host



Domain-based virtual hosting:

Virtual host for Apache is mainly to modify the/application/apache/conf/extra directory under the httpd-vhosts.conf file


Namevirtualhost *:80

#
<virtualhost *:80>
ServerAdmin 15259513** @qq. com managing mailboxes
DocumentRoot "/var/html/www/" The Directory of the home page to which the domain name is accessed
ServerName www.abc.com Domain Name
Serveralias aliases for etiantian.com domain names
Errorlog "|/usr/local/sbin/cronolog/var/logs/apache/%y/%m/error_www_%y%m%d.log"
Customlog "|/usr/local/sbin/cronolog/var/logs/apache/%y/%m/access_www_%y%m%d.log" combined log polling for logs.
</VirtualHost>
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/html/blog/"
ServerName blog.abc.com
Errorlog "Logs/blog-error_log"
Customlog "Logs/blog-access_log" common
</VirtualHost>
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/html/bbs/"
ServerName bbs.abc.com
Errorlog "Logs/bbs-error_log"
Customlog "Logs/bbs-access_log" common
</VirtualHost>


After you change the httpd-vhosts.conf file, you need to authorize it in the Apache master profile.

Vim Httpd.conf adds the following to this profile:

</IfModule>
<directory "/var/html/" > User access to the home page directory
Options -indexes followsymlinks -indexes does not show the directory structure of Apache
AllowOverride None
Order Allow,deny
Allow from all
</Directory>


The Include conf/extra/httpd-vhosts.conf removes the comment from this line.


============================================================


Virtual hosts based on different ports:


Virtual host for Apache is mainly to modify the/application/apache/conf/extra directory under the httpd-vhosts.conf file

Namevirtualhost *:80
Namevirtualhost *:8000
Namevirtualhost *:8080

#
# VirtualHost Example:
# Almost any Apache directive could go into a VirtualHost container.
# The first VirtualHost section was used for all requests and that does not
# match a ServerName or Serveralias in any <VirtualHost> block.
#
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/html/www/"
ServerName www.etiantian.com
Serveralias etiantian.com
Errorlog "|/usr/local/sbin/cronolog/var/logs/apache/%y/%m/error_www_%y%m%d.log"
Customlog "|/usr/local/sbin/cronolog/var/logs/apache/%y/%m/access_www_%y%m%d.log" combined
</VirtualHost>
<virtualhost *:8000>
ServerAdmin [email protected]
DocumentRoot "/var/html/blog/"
ServerName blog.etiantian.com
Errorlog "Logs/blog-error_log"
Customlog "Logs/blog-access_log" common
</VirtualHost>
<virtualhost *:8080>
ServerAdmin [email protected]
DocumentRoot "/var/html/bbs/"
ServerName bbs.etiantian.com
Errorlog "Logs/bbs-error_log"
Customlog "Logs/bbs-access_log" common
</VirtualHost>


After you change the httpd-vhosts.conf file, you need to authorize it in the Apache master profile.

Vim Httpd.conf adds the following to this profile:

</IfModule>
<directory "/var/html/" > User access to the home page directory
Options -indexes followsymlinks -indexes does not show the directory structure of Apache
AllowOverride None
Order Allow,deny
Allow from all
</Directory>


The Include conf/extra/httpd-vhosts.conf removes the comment from this line.





Apache base with different types of virtual hosts

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.