Linux下安装配置JDK和tomcat

时间:2021-03-17 19:12:04


软件版本:
     linux:CentOS6.5
  JDK  :jdk-6u45-linux-i586.bin (下载地址:http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html)
  tomcat: apache-tomcat-6.0.41-deployer


一、安装配置JDK

1.将jdk-6u45-linux-i586.bin 拷贝到/opt/server目录下,并解压:

 sh jdk-6u45-linux-i586.bin

2.设置环境变量,修改文件/etc/profile,在最上面添加如下信息:

JAVA_HOME=/opt/server/jdk1.6.0_45

JRE_HOME=$JAVA_HOME/jre

PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

export JAVA_HOME JRE_HOME PATH CLASSPATH

3.重新登录。

4.检测JDK是否安装成功。使用如下命令检测是否成功:

[root@localhost ~]# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)


二、安装配置tomcat

1.将japache-tomcat-6.0.41-deployer 拷贝到/opt/server目录下,并解压:

tar -zxvf apache-tomcat-6.0.41.tar.gz

2.移动到/usr/local,mv apache-tomcat-6.0.41 /usr/local

3.修改目录名,mv apache-tomcat-6.0.41 apache-tomcat

4.进入tomcat的bin目录, cd apache-tomcat/bin

5.修改启动文件, vim catalina.sh,添加以下内容:

CATALINA_HOME=/usr/local/apache-tomcat/

chmod +x *.sh

6.启动tomcat,./catalina.sh start,在浏览器输入:

http://localhost:8080,测试成功。