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

[经验分享] Ubuntu安装apache tomcat整合

[复制链接]

尚未签到

发表于 2018-11-23 11:48:29 | 显示全部楼层 |阅读模式
  #!/bin/bash
  

  

  

  ##############################################################
  ## /usr/local/src software source
  ## /opt      software
  ## /var/www    web root dir
  ##############################################################
  mkdir -p /var/www
  mkdir -p /opt
  

  ##wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
  ##wget http://mirror.esocc.com/apache//httpd/httpd-2.4.6.tar.gz
  ##http://apr.apache.org/download.cgi
  ##wget http://apache.dataguru.cn/apr/apr-1.4.8.tar.gz
  ##wget http://apache.dataguru.cn/apr/apr-util-1.5.2.tar.gz
  ##wget http://sourceforge.net/projects/pcre/files/pcre/8.33/pcre-8.33.tar.gz
  ##wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
  ##wget http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/source/jk-1.2.31/tomcat-connectors-1.2.31-src.tar.gz
  ##wget http://zlib.net/zlib-1.2.8.tar.gz
  echo "##############thank you for using my shell################# "
  echo "DO you want to install httpd-2.4.6 now?"
  echo "These softwares will be installed :"
  echo "apache-tomcat-7.0.42.tar.gz"
  echo "apr-1.4.8.tar.gz"
  echo "apr-util-1.5.2.tar.gz"
  echo "bzip2-1.0.6.tar.gz"
  echo "httpd-2.4.6.tar.gz"
  echo "pcre-8.33.tar.gz"
  echo "tomcat-connectors-1.2.37-src.tar.gz"
  echo "zlib-1.2.8.tar.gz"
  echo "are you ready??"
  echo "press any key to continue."
  echo "press n to stop."
  read -p "(input y or n):" choose
  if [ "$choose" = "n" ]; then
  echo "good bye"
   exit 0
  else
  echo "start............"
  fi
  echo "==========================="
  echo "install now............."
  echo "==========================="
  

  

  

  echo "please choose no in the following table install to continue install!!!"
  read abc
  

  dpkg-reconfigure dash
  

  

  

  
  function NeedGetsystemsoftware()
  {
  echo "============================apt get files=================================="
  apt-get install -y gcc
  apt-get install -y make
  apt-get install -y perl
  apt-get install -y build-essential
  apt-get install -y libxtst-dev
  }
  

  function CheckAndDownloadFiles()
  {
  echo "============================check files=================================="
  

  if [ -s apr-1.4.8.tar.gz ]; then
   echo "apr-1.4.8.tar.gz [found]"
  else
   echo "Error: apr-1.4.8.tar.gz not found!!!download now......"
   wget -c http://apache.dataguru.cn/apr/apr-1.4.8.tar.gz
  fi
  if [ -s apache-tomcat-7.0.42.tar.gz ]; then
   echo "apache-tomcat-7.0.42.tar.gz [found]"
  else
   echo "Error: apache-tomcat-7.0.42.tar.gz not found!!!download now......"
   wget -c http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
  fi
  if [ -s httpd-2.4.6.tar.gz ]; then
   echo "httpd-2.4.6.tar.gz [found]"
  else
   echo "Error: httpd-2.4.6.tar.gz not found!!!download now......"
   wget -c http://mirror.esocc.com/apache//httpd/httpd-2.4.6.tar.gz
  fi
  if [ -s apr-1.4.8.tar.gz ]; then
   echo "apr-util-1.5.2.tar.gz [found]"
  else
   echo "Error: apr-util-1.5.2.tar.gz not found!!!download now......"
   wget -c http://apache.dataguru.cn/apr/apr-util-1.5.2.tar.gz
  fi
  if [ -s pcre-8.33.tar.gz ]; then
   echo "pcre-8.33.tar.gz [found]"
  else
   echo "Error: pcre-8.33.tar.gz not found!!!download now......"
   wget -c http://sourceforge.net/projects/pcre/files/pcre/8.33/pcre-8.33.tar.gz
  fi
  if [ -s bzip2-1.0.6.tar.gz ]; then
   echo "bzip2-1.0.6.tar.gz [found]"
  else
   echo "Error: bzip2-1.0.6.tar.gz not found!!!download now......"
   wget -c http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
  fi
  
  if [ -s zlib-1.2.8.tar.gz ]; then
   echo "zlib-1.2.8.tar.gz [found]"
  else
   echo "Error: zlib-1.2.8.tar.gz not found!!!download now......"
   wget -c http://zlib.net/zlib-1.2.8.tar.gz
  fi
  
  
  
  if [ -s tomcat-connectors-1.2.37-src.tar.gz ]; then
   echo "tomcat-connectors-1.2.37-src.tar.gz [found]"
  else
   echo "Error: tomcat-connectors-1.2.37-src.tar.gz not found!!!download now......"
   wget -c http://mirrors.cnnic.cn/apache//tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.37-src.tar.gz
  fi
  }
  

  function Installsoftware
  {
  echo "============================install software files=================================="
  cd /usr/local/src
  ##########apache need apr and apr-util
  tar zxvf apr-1.4.8.tar.gz
  cd apr-1.4.8/
  ./configure --prefix=/opt/apr-httpd
  make&&make install
  

  cd /usr/local/src
  tar zxvf apr-util-1.5.2.tar.gz
  cd apr-util-1.5.2
  ./configure --prefix=/opt/apr-util --with-apr=/opt/apr-httpd
  make&&make install
  

  #########pcre need libbz2
  cd /usr/local/src
  tar zxvf bzip2-1.0.6.tar.gz
  cd bzip2-1.0.6
  make&&make install
  

  #########apache need pcre
  cd /usr/local/src
  tar zxvf pcre-8.33.tar.gz
  cd pcre-8.33
  ./configure --prefix=/opt/pcre-httpd --enable-pcregrep-libbz2
  make&&make install
  

  #################apache need ###########################
  cd /usr/local/src
  tar zxvf zlib-1.2.8.tar.gz
  cd zlib-1.2.8
  ./configure --prefix=/opt/zlib
  make&&make install
  

  

  cd /usr/local/src
  tar zxvf httpd-2.4.6.tar.gz
  cd httpd-2.4.6
  ./configure --prefix=/opt/apache --with-apr=/opt/apr-httpd/ --with-apr-util=/opt/apr-util/ --with-z=/opt/zlib --with-pcre=/opt/pcre-httpd --with-mpm=worker --enable-module=so --enable-mods-shared=all --enable-deflate=shared
  

  make&&make install
  

  cat >> /etc/rc.local &1 | tee -a /usr/local/src/find.log
  Installsoftware 2>&1 | tee -a /usr/local/src/installsoft.log
  

  

  function InstallJDKTOMCAT()
  {
  echo "Install tomcat and Jdk now>>>>>>>>>>>>>"
  
  ############### install JDK  ###############
  if [ -s jdk-6u35-linux-x64.bin ]; then
  V64=1
  echo "v64 found"
  else
  V64=0
  echo "v64 no found"
  fi
  if [ -s jdk-6u45-linux-i586.bin ]; then
  V32=1
  echo "v32 found"
  else
  V32=0
  echo "v32 no found"
  fi
  

  if [ "$V64" = 0 ] && [ "$V32" = 0 ]; then
  echo "no jdk-6u found!!"
  exit 0
  fi
  

  

  

  

  echo "==========================="
  echo "instal now............."
  echo "==========================="
  

  if [ "$V64" != 0 ] && [ "$V32" != 0 ]; then
  echo "which JDK version(default 32) you want to install (32=1 64=2) ?"
  read -p "(please input 1 or 2):" JDKVER
  if [ "$JDKVER" = "" ]; then
  JDKVER=1
  fi
  echo "The version you choose is $JDKVER"
  fi
  

  cd /usr/local/src
  

  

  if [ "$JDKVER" = 1 ]; then
  chmod +x jdk-6u45-linux-i586.bin
  ./jdk-6u45-linux-i586.bin
  mv jdk1* /opt/jdk6
  fi
  

  

  if [ "$JDKVER" = 2 ]; then
  chmod +x jdk-6u35-linux-x64.bin
  ./jdk-6u35-linux-x64.bin
  mv jdk1* /opt/jdk6
  fi
  

  if [ "$V64" = 0 ] && [ "$V32" = 1 ]; then
  chmod +x jdk-6u45-linux-i586.bin
  ./jdk-6u45-linux-i586.bin
  mv jdk1* /opt/jdk6
  fi
  

  if [ "$V64" = 1 ] && [ "$V32" = 0 ]; then
  chmod +x jdk-6u35-linux-x64.bin
  ./jdk-6u35-linux-x64.bin
  mv jdk1* /opt/jdk6
  fi
  

  

  

  

  

  

  

  

  cat >> /etc/profile  /opt/tomcat/bin/startup.sh > /opt/apache/conf/httpd.conf
  

  mv /opt/apache/conf/extra/httpd-vhosts.conf /opt/apache/conf/extra/httpd-vhosts.conf.bak
  

  cat >> /opt/apache/conf/extra/httpd-vhosts.conf  /opt/apache/conf/httpd.conf  /opt/apache/conf/extra/mod_jk.conf > /opt/apache/conf/extra/workers.properties >Error.log
  cat /usr/local/src/find.log|grep error >>Error.log
  cat /usr/local/src/installsoft.log|grep error >>Error.log
  cat /usr/local/src/TOMCATapache.log|grep error >>Error.log
  Logs=$(cat /usr/local/src/Error.log)
  echo "$Logs"
  echo "No error? input y or n"
  read ToSee
  if [ "$ToSee" = "n" ]; then
  echo "##########################################################################"
  echo "##########    please check the Error logs         #############"
  echo "##########    /usr/local/src/Error.log          #############"
  echo "##########################################################################"
  exit 0
  else
  echo "##########################################################################"
  echo "##########    Congratulations!!!!!!!!          #############"
  echo "##########   please startup your tomcat and apache server! #############"
  echo "##########  as it is the first time use jdk please use:   #############"
  echo "##########   source /etc/profile              #############"
  echo "##########   /opt/tomcat/bin/startup.sh          #############"
  echo "##########   /opt/apache/bin/apachectl start        #############"
  echo "##########################################################################"
  echo " "
  echo "visit your website at http://\$ip to test your web server"
  echo "note: May it can not access to tomcat manager website"
  echo " "
  echo "visit website at http://\$ip:8080 to manage your tomcat server"
  echo "use the default username :admin passwd:admin"
  echo " "
  echo " "
  echo " "
  echo "note:use apt-get install mysql-server to install your mysqlserver"
  echo " "
  echo " "
  echo " "
  fi
  

  

  

  }
  

  Checkinstall 2>&1 | tee -a /usr/local/src/checkinstall.log
  





运维网声明 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-638643-1-1.html 上篇帖子: apache配置优化(七) 下篇帖子: 两种apache域名跳转法简单完成重定向
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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