Ubuntu安装apache tomcat整合
#!/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 "
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 "
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 "
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 "
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 "
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 "
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 "
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 "
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]