This chapter connect access method articles Apache virtual hosts
———————————————————————————————————————————————
Apache configuration and application
This chapter structure
Apache configuration analysis:
1.Apache connection remains
2.Apache access control
Apache log management:
1. Log split
2.AWStats log analysis
Apache connections remain
Apache holding connection parameters
1.KeepAlive:
whether the connection remains open, OFF closed, ON open
2.KeepAlive 'Timeout
time interval between the maximum connection request repeatedly, over which time two requests disconnection
3.MaxKeepAliveRequests:
The maximum number of requests that can be transmitted once the connection
Apache Access Control Overview
Apache access control
1. Role:
to control access to the site resources
add access authorization for a particular Web site directories
2. The common access control
address of the client restrictions:
user licensing restrictions
Client-based access control address
1. Require configuration item access control, according to the order restrictions
2. useful in <Location>, <Directory>, <Files>, <Limit> configuration section
Common grammar 3.Require configuration items
All granted the Require
the Require All denied
the Require local
the Require [not] <hostname or domain name list> Host
the Require ip <IP address or network List> [not]
# To use placed <RequireAll> when not disable access </ RequireAll> container and specify the appropriate restriction policy in a container
Demo: restrict access to authorized users
Adding user authorization configuration:
[root@localhost named]# cd /etc/httpd/conf/extra
[root@localhost extra]# ls
vhost.conf
[root@localhost extra]# vim vhost.conf
<VirtualHost 192.168.56.131:80>
DocumentRoot "/var/www/html/accp/"
ServerName www.accp.com
ErrorLog "logs/www.accp.com.error_log"
CustomLog "logs/www.accp.com.access_log" common
<Directory "/var/www/html/">
<RequireAll>
Require not ip 192.168.56.130 //添加不允许的IP地址,为测试主机win7的IP地址
Require all granted
</RequireAll>
</Directory>
</VirtualHost>
#此时可以访问accp02网段,不可以访问accp网段
修改完成后按Esc,输入:wq保存退出
[root@localhost extra]# systemctl restart httpd
Black and white list validation setting:
Now enter: www.naccp.com is normal can access the content we write the first page of
But we then enter: www.accp.com Apache will jump to the home page, instead we write the contents of the home page, indicating the success of black and white list settings
Create a user authentication database:
[root@localhost extra]# cd /etc/httpd/conf
[root@localhost conf]# ls
extra httpd.conf magic
[root@localhost conf]# htpasswd -c /etc/httpd/conf/pwd test01
New password: //此处为:abc1234,可自行定义
Re-type new password: //此处重复输入上面的密码
Adding password for user test01
[root@localhost conf]# ls //此时可以看到pwd文件
extra httpd.conf magic pwd
[root@localhost conf]# cat pwd
test01:$apr1$PsatL6Av$SVm5oEaVh6YbnRU4NOBH./ //这个就是test01的密码密文
[root@localhost conf]# htpasswd /etc/httpd/conf/pwd test02
New password:
Re-type new password:
Adding password for user test02
[root@localhost conf]# cat pwd
test01:$apr1$PsatL6Av$SVm5oEaVh6YbnRU4NOBH./
test02:$apr1$XzM8x3.v$Ozy.U6GXVzMaBKB4MKdMd/
[root@localhost conf]# cd extra/
[root@localhost extra]# ls
vhost.conf
[root@localhost extra]# vim vhost.conf
<VirtualHost 192.168.56.134:80>
DocumentRoot "/var/www/html/accp02/"
ServerName www.naccp.com
ErrorLog "logs/www.accp02.com.error_log"
CustomLog "logs/www.accp02.com.access_log" common
<Directory "/var/www/html/">
AuthName "DocumentRoot"
AuthType Basic
AuthUserFile /etc/httpd/conf/pwd
Require valid-user
</Directory>
</VirtualHost>
#具体修改内容见上
[root@localhost extra]# systemctl restart httpd //重启服务