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