linux安装jdk和tomcat

linux安装jdk和tomcat

1.下载:

apache-tomcat-6.0.29.tar.gz

jdk-6u23-linux-i586.bin

2.安装:

将他们拷贝到/home中

打开命令窗口:

进入home:

cd /home

授权:

chmod 755 apache-tomcat-6.0.29.tar.gz

chmod 755 jdk-6u23-linux-i586.bin

安装:

tar zxvf apache-tomcat-6.0.29.tar.gz

./jdk-6u23-linux-i586.bin

移动:

mv apache-tomcat-6.0.29 /usr/local/tomcat6

mv jdk1.6.0_23 /usr/local/jdk6

3.配置

配置环境变量:

vi  /etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1=‘\h:\w\$ ‘
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1=‘# ‘
    else
      PS1=‘$ ‘
    fi
  fi
fi

# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

export JAVA_HOME=/usr/local/jdk6
export JRE_HOME=/usr/local/jdk6/jre
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar


然后执行:

source /etc/profile

配置tomcat启动脚本:

vi  /etc/init.d/tomcat6

#!/bin/bash

export JRE_HOME=/usr/local/jdk6/jre
export JAVA_HOME=/usr/local/jdk6
export CLASSPATH=/usr/local/jdk6/lib/tools.jar:/usr/local/jdk6/lib/dt.jar

start()
{
  killall -9 java
  echo -n $"starting tomcat6 "
  /usr/local/tomcat6/bin/startup.sh
  return 0
}

stop()
{
  echo -n $"shutting down tomcat6 "
  /usr/local/tomcat6/bin/shutdown.sh
  killall -9 java
  return 0
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  *)
	echo $"usage: start | stop"
	exit 1
esac

exit 0


进入脚本目录:

cd /etc/init.d/

授权:

chmod 755 /etc/init.d/tomcat6

 

至此就配置完成了。

输入/etc/init.d/tomcat6 start 即可启动tomcat。

linux安装jdk和tomcat,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。