脚本安装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 "=====================================
"
printf "JDK 1.8.0 ALREADY INSTALLED
"
printf "=====================================
"
echo JDK EXTING...
exit 1
else
printf "=====================================
"
printf "INSTALL JDK 1.8.0........
"
printf "=====================================
"
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 "=====================================
"
printf "TAR JDK 1.8.0 SUCCESSFULLY........
"
printf "=====================================
"
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 "=====================================
"
printf "jdk SUCCESSFULLY!
"
printf "=====================================
"
#
#测试
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 "=====================================
"
printf "TOMCAT 8.0.53 ALREADY INSTALLED
"
printf "=====================================
"
echo TOMCAT EXTING...
exit 1
else
printf "=====================================
"
printf "INSTALL TOMCAT 8.0.53........
"
printf "=====================================
"
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 "=====================================
"
printf "TAR TOMCAT 8.0.53 SUCCESSFULLY........
"
printf "=====================================
"
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 "=====================================
"
printf "tomcat SUCCESSFULLY!
"
printf "=====================================
"
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/