nginx 中用 sed 批量增加配置文件内容

#!/bin/bash
confs=`ls  /etc/nginx/conf.d/cms_vhosts/`
cd /etc/nginx/conf.d/cms_vhosts
for log in $confs;do
  name=`echo ${log} |awk -F '.' '{print $1}'`
  sed -i "/root/aerror_log   /zz_data/nginx_log/${name}.error.log;" $log
  sed -i "/error_log/aaccess_log  /zz_data/nginx_log/${name}.access.log  access;" $log
done

#注:
confs 表示 vhost 里面的每一个配置文件名称
name 表示 配置文件名称单个字符串截取,为域名
sed 为增加访问和错误日志

  

原文地址:https://www.cnblogs.com/lixinliang/p/10245534.html