Apache,tomcat,nginx,apache+tomcat,nginx+tomcat自动化安装脚本

Apache,tomcat,nginx,apache+tomcat,nginx+tomcat自动化安装脚本

 

#!/bin/bash

#Auto Install Apache Tomcat Nginx apache+tomcat nginx+tomcat.

#apache version: 2.2.17       download: http://httpd.apache.org/download.cgi#apache22

#jdk    version: 1.6          download: http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html

#tomcat version: 6.0.23       download: http://tomcat.apache.org/download-60.cgi

#nginx  version: 0.8.54       download: http://nginx.org/en/download.html
 
#执行这个自动化安装脚本需要把apache tomcat jdk nginx的安装包拷贝到/soft目录下.

#apache安装在/opt/conf/apache目录下. nginx安装在/opt/conf/nginx目录下.

#tomcat安装在/opt/conf/tomcat目录下. jdk安装在/opt/conf/jdk目录下.

# 20110413 write: liweizhong   e-mail:[email protected]  QQ:543302969  Version 1.1


IN_SRC=/soft
IN_DIR=/opt/conf

echo "=================Check software development environment.================" 
echo ""
rpm -q  gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel > /dev/null

if  [ "$?" != 0 ] ;
then
echo "Please check your need software"
exit 0
else
echo "software is OK !! "
fi

if [[ ! -d $IN_DIR ]]
  then
  mkdir -p $IN_DIR
fi


function apache_ins {
echo ""
echo "===========================Apache installing============================="
sleep 5
#Auto apache


echo "installing httpd..."

        cd $IN_SRC

        tar jxvf httpd-2.2.17.tar.bz2

        cd httpd-2.2.17

        ./configure --prefix=$IN_DIR/apache --with-mpm=worker --enable-rewrite --enable-deflate --disable-userdir --enable-so

        [ $? != 0 ] && exit

        make

        [ $? != 0 ] && exit

        make install

        [ $? != 0 ] && exit

        echo "Include conf/vhost.conf" >> $IN_DIR/apache/conf/httpd.conf

        sed -i "s/#ServerName/ServerName localhost/g" $IN_DIR/apache/conf/httpd.conf
touch $IN_DIR/apache/conf/vhost.conf
$IN_DIR/apache/bin/apachectl start
echo "$IN_DIR/apache/bin/apachectl start" >> /etc/rc.local
${SERVICES}_ins
sleep 2
echo "==========================Auto Install  finished=========================="
}

 


function tomcat_ins {
echo ""
echo "===========================Tomcat installing============================="
sleep 5
#Auto Install JDK

cd /soft
chmod 700 jdk*
./jdk-6u23-linux-i586.bin
mv jdk1.6.0_23/ /opt/conf/jdk
rm -rf /usr/bin/java
rm -rf /usr/bin/javac
ln -s /opt/conf/jdk/bin/java /usr/bin/java
ln -s /opt/conf/jdk/bin/javac /usr/bin/javac
java -version

sleep 3
javac -version
echo ""
echo ""
echo "====================Auto Install JDK Have finished======================"

#Auto Install tomcat

sleep 5
cd /soft
tar xzvf apache-tomcat-6.0.32.tar.gz
mv apache-tomcat-6.0.32 /opt/conf/tomcat

cat >> /etc/profile << EFF

TOMCAT_HOME=/opt/conf/tomcat

JAVA_HOME=/opt/conf/jdk
   
JRE_HOME=/opt/conf/jdk/jre
   
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$TOMCAT_HOME/bin/

export JAVA_HOME JRE_HOME  PATH TOMCAT_HOME

EFF
source /etc/profile

sleep 3
cd /opt/conf/tomcat/bin
./startup.sh
echo ""
echo ""
echo "=================Already all installation is complete================="
}


function nginx_ins {
echo ""
echo "===========================Nginx installing==========================="
sleep 5
#Auto nginx

echo "installing nginx..."

        cd $IN_SRC

        tar zxvf nginx-0.8.54.tar.gz

        cd nginx-0.8.54

        make_clean

        useradd www

        ./configure --user=www --group=www  --prefix=$IN_DIR/nginx --without-http_rewrite_module --with-http_stub_status_module --with-http_ssl_module 

        [ $? != 0 ] && exit

        make

        [ $? != 0 ] && exit

        make install

        [ $? != 0 ] && exit

       
/opt/conf/nginx/sbin/nginx
echo "$IN_DIR/nginx/sbin/nginx " >> /etc/rc.local
${SERVICES}_ins
sleep 3
echo "===============Auto Install finished================================="
}


echo "Slect install
      1. apache
      2. tomcat+jdk
      3. nginx
      4. apache+tomcat
      5. nginx+tomcat
      6. don't install is now
"

read -p "Please Input 1,2,3,4,5,6:" SERVER_ID
if [[ $SERVER_ID == 5 ]]; then
   SERVICE="nginx"
   SERVICES="tomcat"
elif [[ $SERVER_ID == 4 ]]; then
   SERVICE="apache"
   SERVICES="tomcat"
elif [[ $SERVER_ID == 3 ]]; then
   SERVICE="nginx"
elif [[ $SERVER_ID == 2 ]]; then
   SERVICE="tomcat"
elif [[ $SERVER_ID == 1 ]]; then
   SERVICE="apache"
else
echo ""
echo "Thanks bye!!"
exit
fi

${SERVICE}_ins


 

你可能感兴趣的:(apache,tomcat,nginx,shell脚本,fallenleaves)