自定义shell脚本快速搭建LNMP环境

循环shell脚本模拟 apt install app, 把需要的app写在apps.txt即可。

一、lnmp_install.sh (需要有可执行权限)

#!/bin/bash
#Program function : Lnmp基础环境搭建,基于PHP7.0/MySQL5.7,并安装自定义软件

for app in $(cat apps.txt)
        do
        comment=${app:0:1}
                if [ -n ${app} ]
                        then
                        if [[ ${comment} == "#" ]]
                                then
                                echo "comment">/dev/null
                        else
                                sudo apt-get -y install ${app}
                                if [ $? != 0 ];then
                                        break
                                        echo -e ${app} "\e[0;31m install failed!\e[0m"
                                fi
                                echo -e ${app} "\e[0;33m install success!\e[0m"
                        fi
                fi
        done

二、apps.txt

#lnmp环境搭建 可根据需要调整为其它php版本
nginx
mysql-server
mysql-client
php7.0
php7.0-cgi
php7.0-curl
php7.0-gd
php7.0-mbstring
php7.0-mcrypt
php7.0-mysql
php7.0-soap
php7.0-xml
redis-server
php-redis

#
mysql客户端,有自动补全功能,显示优化
mycli

#常用软件
openconnect
vim
git

 

posted @ 2017-04-20 17:44  yangqi7  阅读(629)  评论(4编辑  收藏  举报