详述CentOS 7中Apache配置与应用(一)
发表于:2026-10-31 作者:千家信息网编辑
千家信息网最后更新 2026年10月31日,Apache连接保持Apache连接保持相关参数KeepAlive是否打开连接保持,OFF关闭,ON打开KeepAlive' Timeout一次连接多次请求之间的最大间隔时间,两次请求超过该时间连接断
千家信息网最后更新 2026年10月31日详述CentOS 7中Apache配置与应用(一)
Apache连接保持
Apache连接保持相关参数
KeepAlive
- 是否打开连接保持,OFF关闭,ON打开
KeepAlive' Timeout
- 一次连接多次请求之间的最大间隔时间,两次请求超过该时间连接断开
- MaxKeepAliveRequests
- 一次连接能够 传输的最大请求数量
Apache访问控制
作用
- 控制对网站资源的访问
- 为特定的网站目录添加访问授权
- 常用访问控制方式
- 客户机地址限制
- 用户授权限制
基于客户端地址的访问控制
使用
Require配置项实现访问控制,按先后顺序限制可用于
<Location>、<Directory>、<Files>、 <Limit>配置段中Require配置项的常见语法
Require all grantedRequire all deniedRequire localRequire [not] host <主机名或域名列表>//使用not禁止访问时要将其置于 容器中并在容器中指定相应的限制策略Require [not] ip 配置实例
在Linux系统中安装DNS、HTTP服务,并设置DNS服务。
[root@localhost ~]# yum install bind httpd -y //安装服务已加载插件:fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com...//省略部分内容...已安装: bind.x86_64 32:9.11.4-9.P2.el7 httpd.x86_64 0:2.4.6-90.el7.centos ...//省略部分内容... 完毕![root@localhost conf]# vim /etc/named.conf //编辑DNS配置文件...//省略部分内容...options { listen-on port 53 { any; }; //更改IP地址为any listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; recursing-file "/var/named/data/named.recursing"; secroots-file "/var/named/data/named.secroots"; allow-query { any; }; //更改监听主机为any...//省略部分内容... :wq[root@localhost conf]# vim /etc/named.rfc1912.zones //编辑区域配置文件...//省略部分内容...zone "kgc.com" IN { //更改域名 type master; file "kgc.com.zone"; //更改区域数据文件名 allow-update { none; };};...//省略部分内容...:wq[root@localhost conf]# cd /var/named/ //进入区域数据文件目录[root@localhost named]# ls //查看目录data dynamic named.ca named.empty named.localhost named.loopback slaves[root@localhost named]# cp -p named.localhost kgc.com.zone //复制区域数据文件[root@localhost named]# vim kgc.com.zone //进入编辑文件$TTL 1D @ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @ A 127.0.0.1www IN A 192.168.144.133 //设置域名解析:wq //保存退出开启两台win 10客户机,并查看客户机IP地址


在Linux系统中进入http服务站点目录,编辑主页内容,并开启DNS、HTTP服务,关闭防火墙及增强性安全功能
[root@localhost named]# cd /var/www/html/ //进入http服务站点目录[root@localhost html]# vim index.html //编辑默认主页this is kgc web
//编辑内容:wq[root@localhost html]# ls //查看index.html [root@localhost html]# cat index.html //查看网页内容this is kgc web
[root@localhost html]# systemctl start httpd.service //启动http服务[root@localhost html]# systemctl start named //启动DNS服务[root@localhost html]# systemctl stop firewalld.service //关闭防火墙[root@localhost html]# setenforce 0 //关闭增强性安全功能使用两台win 10客户机分别访问往网站信息,看服务是否正常提供
在Linux系统中配置HTTP服务配置文件,设置客户机访问权限
[root@localhost html]# vim /etc/httpd/conf/httpd.conf //编辑主配置文件内容(现网中不建议直接修改主配置文件内容,可以重新添加子配置文件进行限制)...//省略部分内容... # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # //在此容器下添加子容器 Require not ip 192.168.144.128 //添加限制访问主机的IP地址(如若限制网段直接添加192.168.144.0/24即可,注意限制网段需填写子网掩码) Require all granted ...//省略部分内容...:wq[root@localhost html]# systemctl restart httpd.service 查看限制的第一台win 10客户端是否还可以访问网站
用户授权限制
配置实例
创建用户认证数据库
[root@localhost html]# htpasswd -c /etc/httpd/conf/pwd test01 //创建用户认证数据库(-c为创建,如果已经存在数据认证文件可以不用-c,直接就可以使用命令添加进认证文件中)New password: //输入设置的密码Re-type new password: //再次输入密码Adding password for user test01 //成功创建[root@localhost html]# cd /etc/httpd/conf //进入目录[root@localhost conf]# ls //查看httpd.conf magic pwd //成功创建文件[root@localhost conf]# cat pwd //查看文件内容test01:$apr1$zDZ/54yz$rUCXaWixaltHE6ZBvjv0h/ //创建的用户及密码添加用户授权配置
[root@localhost conf]# vim httpd.conf...//省略部分内容... # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # AuthName "DocumentRoot" //更改上面的访问控制条目,此条目声明验证信息 AuthType Basic //验证类型为基本验证 AuthUserFile /etc/httpd/conf/pwd //验证文件路径 Require valid-user //设置为授权用户验证 ...//省略部分内容...:wq //保存退出[root@localhost conf]# systemctl restart httpd.service //重新启动服务在客户机中验证配置
内容
文件
配置
服务
部分
限制
客户
用户
客户机
数据
目录
控制
验证
地址
区域
容器
网站
认证
密码
系统
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网科技公司经营范围
互联网科技巨头监管
赫美联合互联网科技
顺玮阁互联网科技
广西拼得多互联网科技有限公司
互联网科技产品
隆华科技工业互联网
科技与互联网哪个更好
互联网大会黑科技排名
花神(南京)互联网科技有限公司
深圳市优智互联网科技有限公司
合肥互联网科技公司公章图片
北京市互联网新科技
互联网科技实习生岗位
城市宝互联网科技有限公司
广州百诚互联网科技有限公司官网
本届互联网大会上的黑科技
云南互联网科技学费
科技信息时代互联网发展
上海旺乐尼互联网科技有限公司
互联网通讯科技
期待互联网科技
嘟嘟瓜互联网科技
百单互联网科技有限公司
撒么互联网科技公司
互联网科技博客
创业天下互联网科技有限公司
和信科技工业互联网
互联网相关科技技术
杭州科技互联网公司有哪些