Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1174833
  • 博文数量: 220
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1769
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-13 16:19
个人简介

努力, 努力, 再努力

文章分类

全部博文(220)

文章存档

2018年(8)

2017年(46)

2016年(75)

2015年(92)

我的朋友

分类: 系统运维

2017-01-02 01:01:26

参考:http://blog.chinaunix.net/uid-639516-id-3342896.html

要求说明: 批量修改apache 的vhost下的配置文件, 添加限制ip并发数,和连接线程速度

环境说明centos6.5

将要修改的文件:
-rw-r--r-- 1 root root  994 1月   2 00:44
-rw-r--r-- 1 root root 1236 1月   2 00:44
-rw-r--r-- 1 root root  994 1月   2 00:44

原配置文件的内容如下
[root@salt-minion1 vhost]# vim


DocumentRoot /home/www/web/abc/public_html
ServerName
ErrorDocument 400 /errpage/400.html
ErrorDocument 401 /errpage/401.html
ErrorDocument 403 /errpage/403.html
ErrorDocument 404 /errpage/404.html
ErrorDocument 405 /errpage/405.html
ErrorDocument 500 /errpage/500.html
CustomLog "logs/_access_log" common
ErrorLog "logs/_error_log"
php_admin_value open_basedir /home/www/web/abc:/tmp

    DeflateCompressionLevel 7
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
    AddOutputFilter DEFLATE css js html htm gif jpg png bmp php



    Options FollowSymLinks
    AllowOverride All
    Require all granted



新增内容如下:
[root@salt-minion1 vhost]# vim rep.txt

   
        MaxConnPerIP 10
   



    BandWidthModule On
    ForceBandWidthModule On
    BandWidth all 204800


关键命令:sed -i '/php_admin/r rep.txt'           解释:  查找到php_admin这行,将rep.txt的内容插入到.cnf中
批量操作步骤:

for cf in $(ls |grep conf); do sed -i '/php_admin/r rep.txt' $cf; done

阅读(10406) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~