首页 > 代码库 > 自定义shell脚本快速搭建LNMP环境(Ubuntu16.04 LTS / PHP7.0)

自定义shell脚本快速搭建LNMP环境(Ubuntu16.04 LTS / PHP7.0)

循环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环境搭建
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

 

自定义shell脚本快速搭建LNMP环境(Ubuntu16.04 LTS / PHP7.0)