腳本安裝Tomcat和java
腳本安裝Tomcat和java
#!/bin/bash
#
#SCRIPT:install_jdk-8u181-linux-x64_apache-tomcat-8.0.53
#AUTHOR:Shinyinfo
#DATE:2018-9-27
#REV:1.0.0
#Description:install jdk1.8.0_181 apache-tomcat-8.0.53 for linux
#Enviroment:Centos6.10
#
#################################################
######## CHECK IF EXIST JDK ########
#################################################
#
JDK_DIR="/usr/local/jdk/jdk1.8.0_181"
JDK_URL="http://192.168.2.27:88/jdk-tomcat/jdk-8u181-linux-x64.tar.gz"
#下載和安裝jdk
if [ -e $JDK_DIR ];then
printf "=====================================\n"
printf "JDK 1.8.0 ALREADY INSTALLED \n"
printf "=====================================\n"
echo JDK EXTING...
exit 1
else
printf "=====================================\n"
printf "INSTALL JDK 1.8.0........ \n"
printf "=====================================\n"
mkdir /usr/local/jdk
cd /usr/local/jdk || { echo "CD USR DIRECTORY FAILED!"; exit 1; }
pwd
wget -q $JDK_URL || { echo "DOWNLOAD PACKAGE FAILED!"; exit 1; }
tar -zxvf jdk-8u181-linux-x64.tar.gz || { echo "DECOMPRESSION PACKAGE FAILED"; exit 1; }
sleep 2
printf "=====================================\n"
printf "TAR JDK 1.8.0 SUCCESSFULLY........ \n"
printf "=====================================\n"
rm -rf /usr/local/jdk/jdk-8u181-linux-x64.tar.gz || { echo "DELETE PACKAGE FAILED!"; exit 1; }
fi
#添加環境變量
if [ `grep "#JDKENV" /etc/profile` ] ;then
echo "ALREADY SET JAVA ENVIRONMENT"
else
echo " " >>/etc/profile
echo "#JDKENV" >> /etc/profile
echo "export JAVA_HOME=/usr/local/jdk/jdk1.8.0_181" >> /etc/profile
echo "export JRE_HOME=/usr/local/jdk/jdk1.8.0_181/jre" >> /etc/profile
echo ‘export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib‘ >> /etc/profile
echo ‘export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH‘ >> /etc/profile
fi
source /etc/profile || { echo "SOME ERROR HAPPEND!"; exit 1; }
#jdk安裝配置完成
printf "=====================================\n"
printf "jdk SUCCESSFULLY! \n"
printf "=====================================\n"
#
#測試
java -version
sleep 2
#
##################################################
######## CHECK IF EXIST TOMCAT ########
#################################################
#
TOMCAT_DIR="/usr/local/tomcat/apache-tomcat-8.0.53"
JDK_URL="http://192.168.2.27:88/jdk-tomcat/apache-tomcat-8.0.53.tar.gz"
#下載和安裝tomcat
if [ -e $TOMCAT_DIR ];then
printf "=====================================\n"
printf "TOMCAT 8.0.53 ALREADY INSTALLED \n"
printf "=====================================\n"
echo TOMCAT EXTING...
exit 1
else
printf "=====================================\n"
printf "INSTALL TOMCAT 8.0.53........ \n"
printf "=====================================\n"
mkdir /usr/local/tomcat
cd /usr/local/tomcat || { echo "CD USR DIRECTORY FAILED!"; exit 1; }
pwd
wget -q $TOMCAT_URL || { echo "DOWNLOAD PACKAGE FAILED!"; exit 1; }
tar -zxvf apache-tomcat-8.0.53.tar.gz || { echo "DECOMPRESSION PACKAGE FAILED"; exit 1; }
sleep 2
printf "=====================================\n"
printf "TAR TOMCAT 8.0.53 SUCCESSFULLY........ \n"
printf "=====================================\n"
rm -rf /usr/local/tomcat/apache-tomcat-8.0.53.tar.gz || { echo "DELETE PACKAGE FAILED!"; exit 1; }
fi
#啟動和開啟防火墻端口
./usr/local/tomcat/apache-tomcat-8.0.53/bin/startup.sh
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/rc.d/init.d/iptables restart
#tomcat安裝配置完成
printf "=====================================\n"
printf "tomcat SUCCESSFULLY! \n"
printf "=====================================\n"
nginx的rpm包下載地址
nginx 的CentOS7版本 http://nginx.org/packages/rhel/7/x86_64/RPMS/
wget 下載網頁目錄下的所以文件
先介紹幾個參數:
-c 斷點續傳(備註:使用斷點續傳要求服務器支持斷點續傳),
-r 遞歸下載(目錄下的所有文件,包括子目錄),
-np 遞歸下載不搜索上層目錄,
-k 把絕對鏈接轉為相對鏈接,這樣下載之後的網頁方便瀏覽,
-L 遞歸時不進入其他主機,
-p 下載網頁所需要的所有文件。
比如:#wget -c -r -np -k -L -p http://www.abc.com/abc/
軟件包下載地址https://pkgs.org/
腳本安裝Tomcat和java