• 脚本_部署LNMP平台


    #!bin/bash
    #功能:部署LNMP平台,实际运行脚本时,需要去除备注.
    #作者:liusingbon
    function menu {                //定义函数menu
             clear
             echo " ##############----Menu----##############"
             echo "# 1. Install Nginx"
             echo "# 2. Install MySQL"
             echo "# 3. Install PHP"
             echo "# 4. Exit Program"
             echo " ########################################"
    }

    function choice {                //定义函数choice
             read -p "Please choice a menu[1-9]:" select
    }

    function install_nginx {            //定义函数install_nginx
             id nginx &>/dev/null                //查看id是否存在
             if [ $? -ne 0 ];then                //判断为假,则添加用户nginx
                useradd -s /sbin/nologin nginx
             fi
               if [ -f nginx-1.12.2.tar.gz ];then    //判断文件nginx-1.12.2.tar.gz是否存在
                   tar -xf nginx-1.12.2.tar.gz   //注意版本的更新
                   cd nginx-1.12.2
                   yum -y install gcc pcre-devel openssl-devel zlib-devel make
                   ./configure --prefix=/usr/local/nginx --with-http_ssl_module   //加载模块
                   make
                   make install
                   ln -s /usr/local/nginx/sbin/nginx/usr/sbin/    //创建软连接型快捷方式
                   cd ..
               else
                   echo "没有找到Nginx源码包"
               fi
    }

    function install_mysql {
             yum -y install gcc gcc-c++ cmake ncurses-devel perl
             id mysql &>/dev/null
             if [ $? -ne 0 ];then
                useradd -s /sbin/nologin mysql
             fi
             if [ -f mysql-5.7.17.tar.gz ];then
                tar -xf mysql-5.7.17.tar.gz   //注意版本的更新
                cd mysql-5.7.17
                cmake .
                make
                make install
                /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/ --
                basedir=/usr/local/mysql/
                chown -R root.mysql /usr/local/mysql
                chown -R mysql /usr/local/mysql/data
                /bin/cp -f /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
                chmod +x /etc/init.d/mysqld
                /bin/cp -f /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
                echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf
                ldconfig     //让动态链接库为系统所共享
                echo 'PATH=$PATH:/usr/local/mysql/bin/' >> /etc/profile
                export PATH
             else
                echo "没有找到mysql源码包"
                exit
             fi
    }

    #当前没有指定启动哪些模块功能,如有需要,请在./configure后面添加模块,如--with-gd等等.
    function install_php {
             yum -y install gcc libxml2-devel
             if [ -f mhash-0.9.9.9.tar.gz ];then
                tar -xf mhash-0.9.9.9.tar.gz
                cd mhash-0.9.9.9
                ./configure
                make
                make install
                cd ..
             if [ ! -f /usr/lib/libmhash.so ];then
                ln -s /usr/local/lib/libmhash.so /usr/lib/
                fi
                ldconfig   //让动态链接库为系统所共享
             else
                echo "没有找到mhash源码包文件"
                exit
             fi
             if [ -f libmcrypt-2.5.8.tar.gz ];then
                tar -xf libmcrypt-2.5.8.tar.gz
                cd libmcrypt-2.5.8
                ./configure
                make
                make install
                cd ..
                   if [ ! -f /usr/lib/libmcrypt.so ];then
                   ln -s /usr/local/lib/libmcrypt.so /usr/lib/
                   fi
                   ldconfig   //让动态链接库为系统所共享
             else
                   echo "没有找到libmcrypt源码包文件"
                   exit
             fi
             if [ -f php-7.3.6.tar.gz ];then
                tar -xf php-7.3.6.tar.gz
                cd php-7.3.6
                ./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql --enable-fpm --enable-mbstring --with-mcrypt  --with-mhash  --with-config-file-path=/usr/local/php5/etc
                mysql=/usr/local/mysql/bin/mysql_config
                make && make install
                /bin/cp -f php.ini-production /usr/local/php5/etc/php.ini
                /bin/cp -f /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf
                cd ..
             else
                 echo "没有找到php源码包文件"
                 exit
             fi
    }

    while :
    do
         menu
         choice
    case $select in
    1)
         install_nginx
    ;;
    2)
         install_mysql
    ;;
    3)
         install_php
    ;;
    4)
         exit
    ;;
    *)
         echo "请选择1-4启动函数模块"
    esac
    done

  • 相关阅读:
    Linq增删查改
    ObjectiveC 的一些记录
    MAX+VC版的RenderMonkey
    PHP校验身份证是否合法
    将小程序scene中的字符串转为对象
    使用JavaScript与Servlet实现客户端与服务器端验证
    分析jdbc程序的编写步骤和原理
    解析Tomcat生成源代码分析javaBean与对象的生成关系
    《Python基础教程》要点(十):充电时刻:导入模块
    《Python基础教程》要点(七):更加抽象:类
  • 原文地址:https://www.cnblogs.com/liusingbon/p/11069815.html
Copyright © 2020-2023  润新知