zoukankan      html  css  js  c++  java
  • (原创)ubuntu14.04 下安装apache+modsecurity

    平台:ubuntu 14.04

    第一步:安装apache

    我建议安装Apache最好用apt-get安装,这样就可以少很多的库支持!!!!如果不嫌麻烦的话可以用源码安装

    输入apt-get install apache2

    如果提示没有这个软件包就更新一下软件包 apt-get install update

    这步安装好了以后apache就可以提供服务了,输入127.0.0.1就可以访问本地网站了

    第二步:安装modsecurity

    这个也和上边的一样,使用

    apt-get install libxml2 libxml2-dev libxml2-utils libaprutil1 libaprutil1-dev libapache2-modsecurity

    安装好了以后就可以查看你的modsecurity的版本号是多少,使用

    dpkg -s libapache2-modsecurity | grep Version

    第三步 配置modsecurity

     

    service apache2 reload

    该命令生效后,会在/var/log/apache2/目录下生成modsecurity的日志文件modsec_audit.log

    使用modsecurity核心规则集

     将我们想起用的规则集放置在以下目录下

    cd /usr/share/modsecurity-crs/activated_rules/

    选择启用base规则集

    for f in $(ls ../base_rules/); do ln -../base_rules/$f; done

    修改apache模块配置,启用规则集

    注意:modsecurity 2.7版本与2.6版本的配置文件有些区别

    (1)2.7版本

    vim /etc/apache2/mods-available/security2.conf

    修改

    <IfModule security2_module>        
    # Default Debian dir for modsecurity's persistent data        
    SecDataDir /var/cache/modsecurity        
    # Include all the *.conf files in /etc/modsecurity.        
    # Keeping your local configuration in that directory        
    # will allow for an easy upgrade of THIS file and        
    # make your life easier        
    IncludeOptional /etc/modsecurity/*.conf        
    IncludeOptional /usr/share/modsecurity-crs/*.conf        
    IncludeOptional /usr/share/modsecurity-crs/activated_rules/*.conf
    </IfModule>

    (2)2.6版本

    ‍‍vim  /etc/apache2/mods-available/mod-security.conf‍‍

    修改

    Include /etc/modsecurity/*.conf
    Include /usr/share/modsecurity-crs/*.conf
    Include /usr/share/modsecurity-crs/activated_rules/*.conf



    以上内容参考:http://www.freebuf.com/articles/web/43559.html?pcoaakbclgkumyws

    启动modsecurity模块
    a2enmod headersa2enmod security2 (版本2.6 a2enmod mod-security)service apache2 restart

    注意!!!!!!!!!!!!!!
    一旦这样修改了以后,使用IP地址就显示403错误!!!!!!为了这个错误,搞了一天,在网上搜各种403错误就是不行,为什么呢????
    查看errol.log 就可以发现,是modsecurity里面禁止了使用IP访问!!!!!!使用localhost就可以正常访问了。。。
    所以,看日志是一个很重要的事儿




     

     

  • 相关阅读:
    HTML5 <input> multiple 属性
    AWS
    new Set() 数组去重
    IAM
    Amazon S3
    Promis 实例
    JS
    React 5
    React 4
    React 3
  • 原文地址:https://www.cnblogs.com/yangxiaocheng/p/4248576.html
Copyright © 2011-2022 走看看