_ Script deployment platform LNMP

bin # / bash!
# Features: LNMP deployment platform, when actually running the script, you need to remove notes.
# Author: liusingbon
function {// define the function of the MENU the MENU
         the Clear
         echo "############## Menu ############## ---- ---- "
         echo" the Install Nginx # 1. "
         echo" # 2. the Install MySQL "
         echo" # 3. the Install PHP "
         echo" 4. Program the Exit # "
         echo" ######################################## "
}

function choice {// defined function Choice
         Read -p "Please Choice A MENU [1-9]:" SELECT
}

function install_nginx defined function {// install_nginx
         ID & Nginx>/ dev / null // id to see if there is
         if [$ -ne 0?]; then // judgment is false, then add the user nginx
            -s the useradd / sbin / nologin Nginx
         Fi
           IF [-f nginx-1.12.2.tar.gz]; // the then determines whether there is document nginx-1.12.2.tar.gz
               tar -xf nginx-1.12.2.tar Note that the updated version .gz //
               CD-Nginx 1.12.2
               yum the install GCC PCRE -Y-devel OpenSSL-devel zlib the make-devel
               ./configure --prefix = / usr / local / Nginx --with // load-http_ssl_module module
               the make
               the make the install
               LN -s / usr / local / Nginx / sbin / Nginx / usr / sbin / soft-linked // Create shortcut
               CD ..
           the else
               echo "not found Nginx Source package"
           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
            the 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 // make dynamic link library system shared
            echo 'the PATH = \ $ the PATH: / usr / local / mysql / bin /' >> / etc / Profile
            Export the PATH
         the else
            echo "not found mysql Source package"
            Exit
         Fi
}

# module which is not currently specified function is activated, if necessary, , add modules, such as the back, etc. --with-gd ./configure.
function install_php {
         yum -Y-devel the install the libxml2 GCC
         IF [-f the mhash-0.9.9.9.tar.gz]; the then
            -xf the mhash-0.9.9.9.tar.gz the tar
            CD the mhash-0.9.9.9
            ./configure
            the make
            the make the install
            CD ..
         IF [-f /usr/lib/libmhash.so!]; the then
            LN -s / usr / local /lib/libmhash.so / usr / lib /
            fi
            ldconfig // make dynamic link library system shared by
         the else
            echo "file not found mhash source package"
            Exit
         fi
         IF [-f libmcrypt-2.5.8.tar.gz]; the then
            the tar-2.5.8.tar.gz -xf libmcrypt
            CD-libmcrypt 2.5.8
            ./configure
            the make
            the make the install
            CD ..
               IF [! -f /usr/lib/libmcrypt.so]; the then
               LN /usr/local/lib/libmcrypt.so -s / usr / lib /
               fi
               ldconfig // make dynamic link library system shared by
         the else
               echo "no found libmcrypt distribution files "
               Exit
         Fi
         IF [-f PHP-7.3.6.tar.gz]; the then
            the tar-7.3.6.tar.gz PHP -xf
            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 / the mysql_config
            the make the make the install &&
            / bin / CP-Production /usr/local/php5/etc/php.ini the php.ini -f
            / bin / CP /usr/local/php5/etc/php-fpm.conf.default -f / usr / local / PHP5 / etc / php-fpm.conf
            CD ..
         the else
             echo "php source package file not found"
             Exit
         Fi
}

the while:
do
     MENU
     Choice
Case in $ SELECT
. 1)
     install_nginx
;;
2)
     install_mysql
;;
. 3)
     install_php
;;
. 4 )
     Exit
;;
*)
     echo "Please select 1-4 start function module"
esac
DONE

Guess you like

Origin www.cnblogs.com/liusingbon/p/11069815.html