系统:suse 11
1、解压
/usr/local # tar xf jdk1.7.0_79.tar -C /usr/local
/usr/local # mv jdk1.7.0_79/ jdk
2、配置环境变量
#vim /etc/profile
JAVA_HOME=/usr/local/jdk
JRE_HOME=/usr/local/jdk/jre
CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$JAVA_HOME/bin:$PATH
export PATH CLASSPATH JAVA_HOME
3、环境变量立即生效并验证
# source /etc/profile
# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
4、解压apache-tomcat并启动服务
# tar zxf apache-tomcat-6.0.37.tar.gz -C /usr/local
启动tomcat服务
/usr/local # cd tomcat/bin
/usr/local/tomcat/bin # ./startup.sh
查看java进程状态
/usr/local/tomcat/bin # ps aux | grep java
查看服务端口
/usr/local/tomcat/bin # netstat -an | grep 8080
tcp 0 0 :::8080 :::* LISTEN
5、编写启动脚本
# vi /etc/init.d/tomcat
#!/bin/bash
# chkconfig: 2345 85 15
# vi /etc/init.d/tomcat
# init script for tomcat precesses
TOMCAT_HOME="/usr/local/tomcat"
case "$1" in
start)
if [ -f $TOMCAT_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
"$TOMCAT_HOME/bin/startup.sh"
fi
;;
stop)
if [ -f $TOMCAT_HOME/bin/shutdown.sh ]
then
echo $"Stopping Tomcat"
"$TOMCAT_HOME/bin/shutdown.sh"
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac
exit 0
6、配置tomcat开机自启动
# chmod +x /etc/init.d/tomcat
# chkconfig tomcat on