06/15
2014
Java & Tomcat 설치 스크립트 (centos 6.5)
웹서버 몇대 설치하려니 스크립트 만드는게 빠를것 같아 만들었음
하는 일
- jdk를 다운받아 설치
- tomcat을 다운받아 설치(압축풀기)
- /web 생성... 이부분은 ~ 시스템에 맞게 수정요망
- iptable 수정(8080포트)
- 톰캣 UTF-8설정
끝
#!/bin/bash -x
##########################################################
#
# Java & Tomcat Setup
# v0.1 : 20140615
#
# by byuri@millky (@origoni)
#
##########################################################
# version 8
jdk_ver="8u5-b13"
tomcat_ver="8.0.8"
# version 7
#jdk_ver="7u60-b19"
#tomcat_ver="7.0.54"
echo "Java & Tomcat Setup"
echo "Java Version = ${jdk_ver:0:1}($jdk_ver)"
echo "Tomcat Version = ${tomcat_ver:0:1}($tomcat_ver)"
yum -y update
yum -y install wget
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/$jdk_ver/jdk-${jdk_ver%-*}-linux-x64.rpm"
rpm -Uvh jdk-${jdk_ver%-*}-linux-x64.rpm
cd /
mkdir web
cd web/
wget http://mirror.apache-kr.org/tomcat/tomcat-${tomcat_ver:0:1}/v$tomcat_ver/bin/apache-tomcat-$tomcat_ver.tar.gz
tar zxvf apache-tomcat-$tomcat_ver.tar.gz
mv apache-tomcat-$tomcat_ver/ tomcat
mv apache-tomcat-$tomcat_ver.tar.gz tomcat
sed -i "/--dport 8080/ d" /etc/sysconfig/iptables
sed -i "/lo -j ACCEPT$/ a -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT" /etc/sysconfig/iptables
/etc/rc.d/init.d/iptables restart
sed -i '/URIEncoding="UTF-8"/ d' /web/tomcat/conf/server.xml
sed -i '/<Connector port="8080" protocol="HTTP/ a URIEncoding="UTF-8"' /web/tomcat/conf/server.xml