1. 程式人生 > >(1) 部署JDK和tomcat

(1) 部署JDK和tomcat

hot tomcat8 輸入 root oot tomcat center onf ini

Tomcat為java開發,需要先部署jdk環境

1、部署jdk

mkdir /application/jdk-1.8.162 -p

cd /application/jdk-1.8.162

下載或上傳jdk源碼包

tar xf jdk-8u162-linux-x64.tar.gz

cp -a jdk1.8.0_162/* ./

rm -rf jdk1.8.0_162

ln -s jdk-1.8.162/ jdk

echo ‘export JAVA_HOME="/application/jdk"‘ >> /etc/profile

echo ‘export JRE_HOME="/application/jdk/jre"‘ >> /etc/profile

echo ‘export CLASSPATH="${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib"‘ >> /etc/profile

echo ‘export PATH="${JAVA_HOME}/bin:${JRE_HOME}/bin:${PATH}"‘ >> /etc/profile

source /etc/profile

[root@lb01 jdk]# java -version

java version "1.8.0_162"

Java(TM) SE Runtime Environment (build 1.8.0_162-b12)

Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

JDK安裝完成

2、部署tomcat

mkdir /application/tomcat-8.0

cd /application/tomcat-8.0

下載或上傳tomcat源碼包

tar xf apache-tomcat-8.0.48.tar.gz

cp -ar apache-tomcat-8.0.48/* ./

ln -s tomcat-8.0/ tomcat

echo ‘ export CATALINA_HOME="/application/tomcat"‘ >> /etc/profile

echo ‘ export CATALINA_BASE="/application/tomcat"‘ >> /etc/profile

echo ‘export PATH="${CATALINA_HOME}/bin:${PATH}"‘ >> /etc/profile

source /etc/profile

下面是tomcat的啟停腳本:

cat >> /etc/init.d/tomcat<<end

#!/bin/bash

#description: Tomcat Start Stop Restart

# processname: tomcat8

#chkconfig: 234 30 80

CATALINA_HOME=/application/tomcat

case \$1 in

start)

sh \$CATALINA_HOME/bin/startup.sh

;;

stop)

sh \$CATALINA_HOME/bin/shutdown.sh

;;

restart)

sh \$CATALINA_HOME/bin/shutdown.sh

sleep 2

sh \$CATALINA_HOME/bin/startup.sh

;;

*)

echo ‘please use : tomcat {start | stop | restart}‘

;;

esac

exit 0

end

/etc/init.d/tomcat start

chkconfig --add tomcat

chkconfig --list|grep tomcat

在瀏覽器中輸入IP:8080,如果出現tomcat界面說明安裝成功

另外也可使用/application/tomcat/bin目錄下的catalina.sh start或start.up 啟動tomcat,使用catalina stop或shutdown.sh關閉tomcat服務

註意:catalina.sh腳本的功能很強大,使用--help查看使用幫助

(1) 部署JDK和tomcat