greatrich 发表于 2013-1-31 00:48:08

Linux下安装JDK和Tomcat

 
安装准备:下载 jdk-6u23-linux-i586.bin
jdk下载路径http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html
apache-tomcat-7.0.12.tar.gz 文件
 
请根据自己的系统版本为32、64位,下载相应的版本
查看、卸载系统自带jdk
 
#rpm –qa |grep gcjjava-1.5.0-gcj-1.5.0.0-29.1.el6.i686libgcj-4.4.4-13.el6.i686 卸载jdk
 
#rpm –e java-1.5.0-gcj-1.5.0.0-29.1.el6.i686 --nodeps#rpm –e libgcj-4.4.4-13.el6.i686 --nodeps 查看jdk 版本
# java --version 
检测javac 命令
#javac 
开始安装:
1.复制下载文件到/opt目录下
# cp jdk-6u23-linux-i586.bin apache-tomcat-7.0.12.tar.gz/opt 
2.赋予 jdk-6u23-linux-i586.bin文件可执行权限
# chmod 777 jdk-6u23-linux-i586.bin 
3.编译二进制文件jdk-6u23-linux-i586.bin
#./ jdk-6u23-linux-i586.bin 
4.编译完成,生成jdk1.6.0_23文件,编辑/etc/profile,在文件末尾添加jdk路径,重新编译/etc/profile 文件
#vi /etc/profile########## 加入如下内容export JAVA_HOME=/opt/jdk1.6.0_23export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/binexport CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH########### source /etc/profile 5.解压apache-tomcat-7.0.12.tar.gz文件。
#tar xvfz apache-tomcat-7.0.12.tar.gz 
6. 解压后发现如下目录apache-tomcat-7.0.12,重命名为tomcat
#mv apache-tomcat-7.0.12 tomcat 
7.到tomcat子目录bin目录下找到catalina.sh 文件。复制文件到/etc/init.d 并改名为tomcat
 
#cd /opt/tomcat/bin/#cp catalina.sh /etc/init.d/tomcat 8.编辑/etc/init.d/tomcat文件.在文件中添加如下文中红色部分,蓝色为方便查找做的标注。下列为tomcat部分内容,不可直接使用。
 
#vi /etc/init.d/tomcat#!/bin/sh# chkconfig: 2345 10 90# description:Tomcat service# Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements.See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the "License"); you may not use this file except in compliance with# the License.You may obtain a copy of the License at##   http://www.apache.org/licenses/LICENSE-2.0### $Id: catalina.sh 1073891 2011-02-23 19:23:59Z markt $# -----------------------------------------------------------------------------CATALINA_HOME=/opt/tomcatJAVA_HOME=/opt/jdk1.6.0_23# OS specific support.   $var _must_ be set to either true or false.cygwin=falseos400=falsedarwin=falsecase "`uname`" inCYGWIN*) cygwin=true;;OS400*) os400=true;;Darwin*) darwin=true;;esac 9.添加tomcat 服务
#chkconfig --add tomcat  
10.关闭和启动tomcat 服务,由此生成的tomcat 没有重启命令
 
#service tomcat stop      #### 关闭tomcat 服务#service tomcat start      #### 启动tomcat 服务 11.查看tomcat 服务运行级别
# chkconfig --list |grep tomcat 
tomcat          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
12.如果345 为关闭状态。执行如下命令设置tomcat为开机自启动。
 
# chkconfig tomcat on 
 
 
 
 
页: [1]
查看完整版本: Linux下安装JDK和Tomcat