分类 一键脚本 下的文章

场景:几十个站点迁移过来,懒得一一配置,索性来个遍历目录下的二级文件夹自动创建成nginx站点配置文件完成站点部署。
业务中除了获取目录名,还有排除已有,使用一个已有的标准配置来生成N多其它配置。
cd到nginx/conf下,创建脚本addsite.sh

florder='/disk2/ftp'
dir=$(ls -l $florder |awk '/^d/ {print $NF}')
for i in $dir
do
    if [ "$i" != 'p7zip_16.02' -a "$i" != 'img.isres.com' -a "$i" != 'img57.isres.com' ];then
        cp -f vhost/img.isres.com.conf vhost/$i.conf 
        sed -i 's/img.isres.com/'$i'/g' vhost/$i.conf 
        
        echo vhost/$i.conf 
    fi
done

测试了几个不同环境,成功顺利完成 自动 安装,启动,配置开机自动启动

#!/bin/sh
yum -y install make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap lsof cmake automake autoconf zlib zlib-devel glibc glibc-devel glib2 libxml glib2-devel libxml2 libxml2-devel bzip2 bzip2-devel libXpm libXpm-devel libidn libidn-devel libtool libtool-ltdl-devel* libmcrypt libmcrypt-devel libevent-devel libmcrypt* curl curl-devel perl perl-Net-SSLeay pcre pcre-devel openldap openldap-devel openldap-clients openldap-servers libjpeg libpng libjpeg-devel libjpeg-6b libjpeg-devel-6b libpng-devel libtiff-devel freetype freetype-devel gd gd-devel
wget https://www.isres.com/file/redis-4.0.1.tar.gz
tar -zxvf redis-4.0.1.tar.gz
cd redis-4.0.1
make
cd src
make install PREFIX=/usr/local/redis
#将配置文件移动到redis目录
cd  ../
mv redis.conf /usr/local/redis/redis.conf
cp /usr/local/redis/redis.conf /usr/local/redis/redis.conf.bak
#redis数据默认目录/data/redisdb
sed -i 's/dir .\//dir \/data\/redisdb/g' /usr/local/redis/redis.conf
mkdir -p /data/redisdb
#后台运行
sed -i 's/daemonize no/daemonize yes/g' /usr/local/redis/redis.conf
#开机启动配置
echo  "/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf" >> /etc/rc.local
#启动redis
/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf

install_redis.zip

脚本特点

  1. php7.2.1新版本
  2. nginx支持lua扩展和安装ngfw防火墙
  3. 安装默认创建站点通过ip访问的,WEB目录位于 /home/public_html/
  4. 默认会加一条开启80端口的规则到防火墙
  5. 仅支持centos6 64位系列
  6. 兼容的一键脚本不好搞,改了一些。

奇葩的有此系统没有预先安装好 gcc*和make
索性
yum install -y gcc*,make



- 阅读剩余部分 -