HTTPD2.4的安装与配置详解

时间:2019-10-31 21:05:47   收藏:0   阅读:92

HTTPD2.4的安装与配置详解

httpd2.4

httpd2.4在centos6上的源码安装

yum install gcc
yum install gcc-c++
yum install openssl-devel
yum install perl
yum install pcre-devel
cd apr-1.5.2
./configure --prefix=/usr/local/apr
make && make install
cd ../apr-util-1.5.3
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install
 cd httpd-2.4.10
./configure --prefix=/usr/local/apache --sysconf=/etc/httpd2.4 --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
make && make install
#chkconfig: 35 85 21 #设定默认启动级别3、5,85为启动优先级 21为关闭优先级,数字越小,优先级越高
#description:wwww #描述信息 
export PATH=/usr/local/apache/bin:$PATH

Centos7安装配置httpd

内置status状态页面启用

<location /server-status>
    SetHandler server-status
    Require ip 192.168.10.1 #允许访问的主机
</location>

页面缓存配置

防盗链配置

<Directory "/var/www/html"> 
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    RewriteEngine On #启用rewrite
    RewriteCond %{HTTP_REFERER} !^http://192.168.10.120/.*$  #匹配所有非直接访问本机的请求
    RewriteCond %{HTTP_REFERER} !^http://192.168.10.120/*$
    RewriteRule .*\.(gif|swf|jpg)$ http://192.168.10.120/error.png [R,NC] #对匹配到的请求进行重定向,返回指定页面或资
</Directory> 
    #返回的资源类型不能与匹配项相同,否则会陷入循环
    #RewriteCond 匹配条件
    #RewriteRule 重写规则
    #%{HTTP_REFERER} 引导用户代理到当前页的前一页的地址
    #[NC]指的是不区分大小写,[R]强制重定向redirect
    #[L]表示如果能匹配本条规则,那么本条规则是最后一条(Last),忽略之后的规则

隐藏Apache版本号

ServerTokens Prod #返回的头部信息中版本信息
ServerSignature Off
#ServerTokens Major|Minor|Minimal|ProductOnly|OS|Full
    #Prod[uctOnly] 只显示服务名-->Server:Apache
    #Major 服务/主版本号  Server:Apache/2
    #Minor 服务/主版本号.次版本号  Server:Apache/2.4
    #Min[imal] 服务/主版本号.次版本号.末版本号  Server:Apache/2.4.6
    #Min[imal] 服务/主版本号.次版本号.末版本号(系统类型)  Server:Apache/2.4.6(CentOS)
    #Full 显示全部相关信息
#ServerSignature 控制由系统生成的页面(错误信息,mod_proxy ftp directory listing等等)的页脚中如何显示信息
#注设置需要声明在全局配置中

虚拟主机配置

httpd2.4访问控制

原文:https://www.cnblogs.com/lastyear/p/11773589.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!