设为首页 收藏本站
查看: 615|回复: 0

lamp 架构搭建shell脚本

[复制链接]

尚未签到

发表于 2018-8-28 13:50:52 | 显示全部楼层 |阅读模式
  #!/bin/bash
  #lamp_install
  #definevariables
  LY=lamp.tar.gz
  DES_PATH=/usr/local/
  YB_PATH=/usr/local/src/
  SOU_PATH=/usr/src/
  #lamp_check
  lamp_check (){
  [ ! -f$YB_PATH/$LY ] && echo "not found lamp.tar.gz" &&exit 1
  #yum check
  yum grouplist1>/dev/null
  [ $? -ne 0 ]&& echo "ERROR: YUM NOT SET" && exit 1
  #DevelopmentTools install
  yum groupinstall"Development Tools" -y 1>/dev/null
  wait
  tar xf$YB_PATH/$LY -C $YB_PATH
  }
  #apache_install
  apache_install(){
  #check
  [ ! -f$YB_PATH/bao/apr-1.4.6.tar.bz2 ] && echo "not foundapr-1.4.6.tar.bz2" && exit 1
  [ ! -f$YB_PATH/bao/apr-util-1.5.1.tar.bz2 ] && echo "not foundapr-util-1.5.1.tar.bz2" && exit 1
  [ ! -f$YB_PATH/bao/httpd-2.4.3.tar.gz ] && echo "not foundhttpd-2.4.3.tar.gz" && exit 1
  #jieya
  tar xf$YB_PATH/bao/apr-1.4.6.tar.bz2 -C $SOU_PATH
  tar xf$YB_PATH/bao/httpd-2.4.3.tar.gz -C $SOU_PATH
  tar xf$YB_PATH/bao/apr-util-1.5.1.tar.bz2 -C $SOU_PATH
  cd $SOU_PATH
  #apr-1.4.6install
  cd apr-1.4.6/
  if [ -xconfigure ];then
  ./configure --prefix=/usr/local/apr 1>/dev/null
  if [ $? -eq 0 ];then
  make 1>/dev/null
  if [ $? -eq 0 ];then
  makeinstall 1>/dev/null
  if [ $? -eq 0];then
  clear;echo"apr-1.4.6 install success"
  else
  echo"apr-1.4.6 install fail";exit 1
  fi
  else
  echo "apr-1.4.6 makefail";exit 1
  fi
  else
  echo "apr-1.4.6 configurefail";exit 1
  fi
  else
  echo"warnning: not found configure";exit 1
  fi
  #apr-util-1.5.1install
  cd../apr-util-1.5.1/
  if [ -xconfigure ];then
  ./configure --prefix=/usr/local/apr-util  1>/dev/null
  if [ $? -eq 0 ];then
  make 1>/dev/null
  if [ $? -eq 0 ];then
  makeinstall 1>/dev/null
  if [ $? -eq 0];then
  clear;echo"apr-util-1.5.1 install success"
  else
  echo"apr-util-1.5.1 install fail";exit 1
  fi
  else
  echo "apr-util-1.5.1make fail";exit 1
  fi
  else
  echo "apr-util-1.5.1 configurefail";exit 1
  fi
  else
  echo"warnning: not found configure";exit 1
  fi
  #apache install
  yum install zlib-devel  -y 1>/dev/null
  wait
  yum installopenssl-devel -y  1>/dev/null
  wait
  yum installpcre-devel -y  1>/dev/null
  wait
  cd../httpd-2.4.3/
  if [ -xconfigure ];then
  ./configure --prefix=/usr/local/apache2--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/--enable-disk-cache --enable-static-support --enable-static-ab--disable-userdir --with-mpm=prefork --disable-ipv6  --with-sendfile 1>/dev/null
  if [ $? -eq 0 ];then
  make 1>/dev/null
  if [ $? -eq 0 ];then
  makeinstall 1>/dev/null
  if [ $? -eq 0];then
  clear;echo"httpd-2.4.3 install success"
  else
  echo"httpd-2.4.3 install fail";exit 1
  fi
  else
  echo "httpd-2.4.3make fail";exit 1
  fi
  else
  echo "httpd-2.4.3 configurefail";exit 1
  fi
  else
  echo"warnning: not found configure";exit 1
  fi
  }
  #mysql_install
  mysql_install(){
  cd $YB_PATH/bao/
  #install pre
  groupadd mysql
  useradd -g mysqlmysql
  rpm -icmake-2.6.4-7.el5.i386.rpm
  yum removemysql-server mysql mysql-devel  ncurses-devellibtool bison gcc*  -y 1>/dev/null
  #install
  [  ! -f $YB_PATH/bao/mysql-5.5.29.tar.gz ]&& echo "not found mysql-5.5.29.tar.gz" && exit 1
  tar xf $YB_PATH/mysql-5.5.29.tar.gz-C $SOU_PATH
  cd mysql-5.5.29/
  cmake  \
  if [ $? -eq 0 ];then
  make 1>/dev/null
  if [ $? -eq 0 ];then
  makeinstall 1>/dev/null
  if [ $? -eq 0];then
  clear;echo"mysql-5.5.29 install success"
  else
  echo"mysql-5.5.29 install fail";exit 1
  fi
  else
  echo "mysql-5.5.29make fail";exit 1
  fi
  else
  echo "mysql-5.5.29 cmakefail";exit 1
  fi
  #tiaoguoyumingjiexi
  cp support-files/etc/my.cnf
  wait
  sed -i -r '/socket/a\skip-name-resolve      = 1' /etc/my.cnf
  #start mysql
  /etc/init.d/mysqlsource  start
  [ $? -ne 0 ]&& echo "mysql start fail" && exit 1
  }
  #phpinstall
  php_install () {
  cd $YB_PATH/bao/
  #check
  [ ! -f$YB_PATH/bao/libiconv-1.14.tar.gz ] && echo "not foundlibiconv-1.14.tar.gz" && exit 1
  [ ! -f$YB_PATH/bao/libmcrypt-2.5.8.tar.gz ] && echo "not foundlibmcrypt-2.5.8.tar.gz " && exit 1
  [ ! -f$YB_PATH/bao/mhash-0.9.9.9.tar.gz ] && echo "not foundmhash-0.9.9.9.tar.gz " && exit 1
  [ ! -f$YB_PATH/bao/mcrypt-2.6.8.tar.gz ] && echo "not foundmcrypt-2.6.8.tar.gz" && exit 1
  [ ! -f$YB_PATH/bao/php-5.4.11.tar.bz2 ] && echo "not foundphp-5.4.11.tar.bz2" && exit 1
  tar xf$YB_PATH/bao/libiconv-1.14.tar.gz -C $SOU_PATH
  tar xf$YB_PATH/bao/libmcrypt-2.5.8.tar.gz  -C$SOU_PATH
  tar xf$YB_PATH/bao/mhash-0.9.9.9.tar.gz  -C$SOU_PATH
  tar xf$YB_PATH/bao/mcrypt-2.6.8.tar.gz  -C$SOU_PATH
  tar xf$YB_PATH/bao/php-5.4.11.tar.bz2 -C $SOU_PATH
  #libiconv-1.14install
  cd$SOU_PATH/libiconv-1.14
  if [ -xconfigure ];then
  ./configure --prefix=/usr/local/--with-apr=/usr/local/apr 1>/dev/null
  if [ $? -eq 0 ];then
  make 1>/dev/null
  if [ $? -eq 0 ];then
  makeinstall 1>/dev/null
  if [ $? -eq 0];then
  clear;echo"libiconv-1.14 install success"
  else
  echo"libiconv-1.14 install fail";exit 1
  fi
  else
  echo "libiconv-1.14make fail";exit 1
  fi
  else
  echo "libiconv-1.14 configurefail";exit 1
  fi
  else
  echo"warnning: not found configure";exit 1
  fi
  #libmcrypt-2.5.8install
  cd../libmcrypt-2.5.8
  if [ -xconfigure ];then
  ./configure 1>/dev/null
  if [ $? -eq 0 ];then
  make 1>/dev/null
  if [ $? -eq 0 ];then
  makeinstall 1>/dev/null
  if [ $? -eq 0];then
  clear;echo"libmcrypt-2.5.8 install success"
  else
  echo"libmcrypt-2.5.8 intall fail";exit 1
  fi
  else
  echo "libmcrypt-2.5.8make fail";exit 1
  fi
  else
  echo "libmcrypt-2.5.8 configurefail";exit 1
  fi
  else
  echo"warnning: not found configure";exit 1
  fi
  #chongxinjiazaimokuai
  /sbin/ldconfig
  cd libltdl/
  if [ -xconfigure ];then
  ./configure --enable-ltdl-install1>/dev/null
  if [ $? -eq 0 ];then
  make 1>/dev/null
  if [ $? -eq 0 ];then
  makeinstall 1>/dev/null
  if [ $? -eq 0];then
  clear;echo"libltdl install success"
  else
  echo"libltdl intall fail";exit 1
  fi
  else
  echo "libltdl makefail";exit 1
  fi
  else
  echo "libltdl configurefail";exit 1
  fi
  else
  echo"warnning: not found configure";exit 1
  fi
  #mhash-0.9.9.9install
  cd$SOU_PATH/mhash-0.9.9.9
  if [ -xconfigure ];then
  ./configure  1>/dev/null
  if [ $? -eq 0 ];then
  make 1>/dev/null
  if [ $? -eq 0 ];then
  makeinstall 1>/dev/null
  if [ $? -eq 0];then
  clear;echo"mhash-0.9.9.9 install success"
  else
  echo"mhash-0.9.9.9 intall fail";exit 1
  fi
  else
  echo "mhash-0.9.9.9make fail";exit 1
  fi
  else
  echo "mhash-0.9.9.9 configurefail";exit 1
  fi
  else
  echo"warnning: not found configure";exit 1
  fi
  #mcrypt-2.6.8install
  cd../mcrypt-2.6.8
  if [ -xconfigure ];then
  ./configure 1>/dev/null
  if [ $? -eq 0 ];then
  make 1>/dev/null
  if [ $? -eq 0 ];then
  makeinstall 1>/dev/null
  if [ $? -eq 0];then
  clear;echo"mcrypt-2.6.8 install success"
  else
  echo"mcrypt-2.6.8 intall fail";exit 1
  fi
  else
  echo "mcrypt-2.6.8make fail";exit 1
  fi
  else
  echo "mcrypt-2.6.8 configurefail";exit 1
  fi
  else
  echo"warnning: not found configure";exit 1
  fi
  #php-5.4.11install
  cd ../php-5.4.11
  yum installlibxml2-devel curl-devel libjpeg-devel freetype-devel net-snmp-devel -y  1>/dev/null
  wait
  if [ -xconfigure ];then
  ./configure --prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --enable-fpm--with-fpm-user=apache --with-fpm-group=apache --with-pcre-regex --with-zlib--with-bz2 --enable-calendar --disable-phar --with-curl  --with-freetype-dir --enable-gd-native-ttf--enable-gd-jis-conv --with-mhash --enable-mbstring --with-mcrypt--enable-pcntl --enable-xml --disable-rpath --enable-shmop --enable-sockets--enable-zip --enable-bcmath --with-snmp --disable-ipv6 --disable-rpath--disable-debug --with-apxs2=/usr/local/apache2/bin/apxs 1>/dev/null
  if [ $? -eq 0 ];then
  make ZEND_EXTRA_LIBS='-liconv'1>/dev/null
  if [ $? -eq 0 ];then
  makeinstall 1>/dev/null
  if [ $? -eq 1];then
  clear;echo"php-5.4.11 install success"
  else
  echo"php-5.4.11 intall fail";exit 1
  fi
  else
  echo "php-5.4.11 makefail";exit 1
  fi
  else
  echo "php-5.4.11 configurefail";exit 1
  fi
  else
  echo"warnning: not found configure";exit 1
  fi
  #xiugaipeizhiwenjian
  cpphp.ini-production /usr/local/php/etc/php.ini
  sed -i '/AddTypeapplication\/x-gzip .gz .tgz/a\   AddType application\/x-httpd-php .php'/usr/local/apache2/conf/httpd.conf
  sed -i's/DirectoryIndex index.html/DirectoryIndex index.php/'/usr/local/apache2/conf/httpd.conf
  #qi dong php duli fu wu
  ln -s/usr/local/apache2/bin/apachectl /etc/init.d/php-fpm
  service php-fpmstart
  }
  lamp_check
  apache_install
  mysql_install
  php_install


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-557815-1-1.html 上篇帖子: Shell 获取 Linux 服务器的 MAC(通用,不依赖网卡名称) 下篇帖子: Shell脚本概念
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表