LAMP or LNMP automatic installation script (function thought writing)

Source: Internet
Author: User

#!/bin/bash# date: 2016-03-12# desc: lan/mp auto install script #  Author: Djoker#function area#<--------------------- Start----------------------------------------> #function:  check errorruncheck () {if [ $1  != 0 ];then  echo  "------------------------"   echo  "| Error,please check log| "   echo  "------------------------"   exit 1fi} #function:  yum install  base packetsyumins () {while [ -n  "$"  ]do    yum -y  install $1     runcheck $?    echo     echo  "$1 is install ......over!"     echo    sleep 1    shiftdone} #function:  install mysqlinstall_mysql_func () {cd /tmpif [ -e mysql-5.5.22.tar.gz ];then  echo  "File is exist!!!" Else  wget http://down1.chinaunix.net/distfiles/mysql-5.5.22.tar.gz  runcheck $? Fitar vxf mysql-5.5.22.tar.gzcd mysql-5.5.22cmake -dcmake_install_prefix=/usr/local/mysql  -dmysql_datadir=/usr/local/mysql/data -dsysconfdir=/etc -dwith_myisam_storage_engine=1 - Dwith_innobase_storage_engine=1 -dwith_memory_storage_engine=1 -dwith_readline=1 -dmysql_unix_ Addr=/var/lib/mysql/mysql.sock -dmysql_tcp_port=3306 -denabled_local_infile=1 -dwith_partition_ Storage_engine=1 -dextra_charsets=all -ddefault_charset=utf8 -ddefault_collation=utf8_general_ Ci -wno-devruncheck $?make && make installruncheck $?} #function:  config mysqlconfig_mysql_func () {groupadd mysqluseradd -g mysql  Mysqlchown -r mysql.mysql /usr/local/mysqlchmod +x /tmp/mysql-5.5.22/scripts/mysql_install_db/tmp/mysql-5.5.22/scripts/mysql_install_db --basedir=/usr/local/ mysql --datadir=/usr/local/mysql/data --user=mysqlruncheck $?cp -a /tmp/mysql-5.5.22/ support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqldecho  "PATH=\ $PATH:/usr/local/mysql/bin " >> /etc/profilechkconfig --add mysqldservice mysqld  startchkconfig mysqld onruncheck $?} #function:  install phpinstall_php_func () {cd /tmpif [ -e  libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpm ];then  echo  "file aready is  install . " else  wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/rpms/ libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpm  rpm --nodeps -i  libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpmfiif [ -e php-5.4.6.tar.bz2 ];then   echo  "File is exit!!! " Else  wget wget http://down1.chinaunix.net/distfiles/php-5.4.6.tar.bz2  runcheck  $?fitar vxf php-5.4.6.tar.bz2cd php-5.4.6./configure --prefix=/usr/local/php -- enable-fpm  --with-mcrypt=/usr/local/libmcrypt --with-zlib --enable-mbstring -- with-openssl --with-mysql --with-mysqli --with-mysql-sock --with-gd --with-jpeg-dir=/ usr/lib --enable-gd-native-ttf  --enable-pdo --with-pdo-mysql --with-gettext -- with-curl --with-pdo-mysql --enable-sockets --enable-bcmath --enable-xml --with-bz2  --enable-zip --enable-freetypruncheck $?make && make installruncheck  $?} #function:  config phpconfig_php_func () {cp /tmp/php-5.4.6/php.ini-development /usr/local/ php/etc/php.ini cp /tmp/php-5.4.6/sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.confecho& nbsp;‘ #!/bin/sh  # datetime: 2013-09-16# author: lianbaikai# site:http:// www.ttlsa.com/html/3039.html# chkconfig:   - 84 16   #  Source function library.  . /etc/rc.d/init.d/functions   # source  networking configuration.  . /etc/sysconfig/network   # check  that networking is up.  [  "$NETWORKING"  =  "no"  ] & & exit 0   phpfpm= "/USR/LOCAL/PHP/SBIN/PHP-FPM"   prog=$ (basename $ {PHPFPM})    lockfile=/var/lock/subsys/phpfpm start ()  {      [  -x ${phpfpm} ] | |  exit 5      echo -n $ "starting  $prog: "        daemon ${phpfpm}    retval=$?      echo      [  $retval  -eq 0 ]  && touch  $lockfile       return  $retval   }    stop ()  {      echo -n $ "Stopping  $prog: "       killproc  $prog  -quit      retval=$ ?      echo      [  $retval  -eq 0  ] && rm -f  $lockfile       return  $retval   }   restart ()  {      configtest | |  return $?      stop      start   }   reload ()  {      configtest | |  return $?      echo -n $ "reloading  $prog: "       killproc $ {phpfpm} -hup      retval=$?      echo   }   force_reload ()  {      restart  }    configtest ()  {    ${phpfpm} -t}   rh_status ()  {       status  $prog   }   rh_status_q ()  {       rh_status >/dev/null 2>&1  }   case   "$"  in      start)            rh_status_q && exit 0           $1          ;;       stop) &NBSP;&NBSP;&NBsp;       rh_status_q | |  exit 0          $1           ;;       restart|configtest)            $1          ;;       reload)           rh_ status_q | |  exit 7          $1           ;;       status)           rh_ status          ;;       *)           echo $ " Usage: $0 {start|stop|status|restart|reload|configtest} "&nbSp;         exit 2  esac '  > /etc/ INIT.D/PHP-FPMCHMOD&NBSP;+X&NBSP;/ETC/INIT.D/PHP-FPMCHKCONFIG&NBSP;--ADD&NBSP;PHP-FPM} #function:  install  httpdinstall_httpd_func () {cd /tmpif [ -e httpd-2.2.9.tar.bz2 ];then   echo  "File is exit!!!" Else  wget http://down1.chinaunix.net/distfiles/httpd-2.2.9.tar.bz2  runcheck $? fitar vxf httpd-2.2.9.tar.bz2cd httpd-2.2.9./configure --prefix=/usr/local/apache -- Enable-so --enable-cgi --enable-rewreite --with-zlib --with-pcre --enable-modules=all  --enable-mpms-shared=all runcheck $?make && make installruncheck $ ?} #function:  config httpdconfig_httpd_func () {echo  "1"} #function:  install nginxinstall_ Nginx_func () {Cd /tmpif [ -e nginx-1.2.1.tar.gz ];then  echo  "File is exit!!!" Else  wget http://down1.chinaunix.net/distfiles/nginx-1.2.1.tar.gz  runcheck $? Fitar xvf nginx-1.2.1.tar.gzcd nginx-1.2.1./configure  --prefix=/usr/local/nginx  --with-select_module --with-http_ssl_module --with-http_realip_module --with-http_image_ Filter_module --with-http_flv_module --with-http_mp4_module --with-http_stub_status_module  --with-debugruncheck $?make && make installruncheck $?} #function:  config nginx#config_nginxf_func () {#}#<--------------------- Stop----------------------------------------> #mainechowhile  truedo  read -p  do  you want to running script ? [y| N]: " choise  if [ -n " $choise " ];then    if [   $choise  =  "Y"  ] | | [  $choise  =  "y" &nBSP;]  ;then      break    elif [  $choise  =   "N"  ] | |  [  $choise  =  "n"  ] ;then      exit 1     else       echo  "please input y| N !,try agint "      echo    fi  else      echo  "please input y| N !,try agint "    echo  fidone#install base packetsyumins  vim make gcc openssl openssl-devel#install_MySQLecho  "check mysql  Deps packets "yumins cmake ncurses-devel ncurses-libsecho " start install  MySQL!!! " sleep 1install_mysql_funcruncheck $?echo  "Start config mysql" Config_mysql_funcecho   "mysql install end !!!" Sleep 1#install_phpecho  "Check php deps packets" yumins libxml2-devel bzip2  bzip2-devel libcurl-devel gd gd-devel libgcrypt  libjpeg*  libpng-develecho  "start install php!!!" sleep 1install_php_funcruncheck $?echo  "start config php" config_php_funcecho  " php install end !!! " sleep 1while truedo    read -p  ' do you want to  INSTALL&NBSP;NGINX&NBSP;OR&NBSP;HTTPD,&NBSP;1&NBSP;IS&NBSP;NGINX&NBSP;,&NBSP;2&NBSP;IS&NBSP;HTTPD&NBSP;[1|2]:   '   hnchoise    if [  $hnchoise   -eq 1 ];then          #install_httpd          echo  "START&NBSP;INSTALL&NBSP;HTTPD!!!"         sleep 1         Install_httpd_func        runcheck $?         echo  "start config httpd !!!"         config_httpd_func         echo  "httpd install end !!!"         sleep 1         break    elif [  $hnchoise  -eq 2 ];then         #install_Nginx        echo  "start install  Nginx!!! "        install_nginx_func       runcheck  $?       echo  "nginx install end !!!"        sleep 1       break     else        echo  "PLEASE&NBSP;INPUT&NBSP;1&NBSP;OR&NBSP;2&NBSP; conntinue?  "       echo    fidoneechoecho "-- ---------------' echo  ' | Install is end!| ' echo  '-----------------'

This article is from the "Anka" blog, make sure to keep this source http://anka0501.blog.51cto.com/10129669/1750715

LAMP or LNMP automatic installation script (function thought writing)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.