One, the type of virtual host
Domain-based virtual host
IP-based virtual host
Port-based virtual host
Second, this example is the implementation of a domain-based virtual host
Practice :(1) create g, Z, and C three directories under the /website directory , respectively, as
www.ggg.com,www.zzz.com,www.ccc.com Web root directory for three sites
(2) set up domain Name server resolution www.ggg.com,www.zzz.com,www.ccc.com Parse the same IP Address
(3) requires that logs from three sites be stored in a /var/log/httpd directory under , and use the same file , that is, access logs are put
to Access.log, the error log is placed under error.log , the error log
level set to notice, Access logging time , client address , requested URL Path , Request Method , the child that responds to the request
Process ID, requested file , Browser type and other information
(4) configure both logs to meet at least 10M And then we do the rotation . , and save up to 5 a rotation file
(5) Set /website/sxjy/private directory only allows 172.16.0.0/16 address access to a network segment
(6) Set /website/sxkj/finance allow only authenticated and authorized users to access , specific user name set yourself
(1) Mkdir-p/website/{g,z,c}
cd/website/a
Vim index.html
Wilcome to GGG Page
Do the same with other files
Mkdir-p/website/a/{prvite,finance}
Cp/website/a/index.html/website/a/private
Cp/website/a/index.html/website/a/finance
(2) Note: In the client settings vim/etc/hosts
10.0.10.103 www.ggg.com
10.0.10.103 www.zzz.com
10.0.10.103 www.ccc.com
You can also use the DNS server plus a option to
(3) Writing of configuration files
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "/WEBSITE/AAA"
ServerName www.aaa.com
Errorlog "/var/log/httpd/error.log"
Customlog "/var/log/httpd/access.log" common
</VirtualHost>
Two other ibid.
(4) Writing of log files
Under the/ETC/LOGROTATE.D
VIM website
/var/log/httpd/*log
{
size=10m
Rotate 5
}
Roughly so
(5)
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "/WEBSITE/AAA"
ServerName www.aaa.com
Errorlog "/var/log/httpd/error.log"
Customlog "/var/log/httpd/access.log" common
<Directory/website/a/private>
Require all denied
Require IP 172.16.0.0/16
</Directory>
<Directory/sxjy>
AuthType Basic
AuthName "Restricted Files"
Authbasicprovider file
AuthUserFile "/usr/local/httpd/passwd/password"
Require User User03
</Directory>
</VirtualHost>
cd/usr/local/
# htpasswd-c/usr/local/httpd/passwd/password user03
Oh, man!
Apache Virtual machine Implementation is commonly known as "one machine multi-station" "Instance article