本文詳細講解Linux系統下JDK、Tomcat的安裝
Jdk安裝:
[root@b home]# ls
jdk-1_5_0_12-linux-i586-rpm.bin lost+found Oracle
1、將jdk進行解壓
[root@b home]# ./jdk-1_5_0_12-linux-i586-rpm.bin
2、將解壓文件copy到/usr/Java下
[root@b home]# cp jdk-1_5_0_12-linux-i586.rpm /usr/java
[root@b home]# cd /usr/java
3、進行安裝
[root@b java]# rpm -ivh jdk-1_5_0_12-linux-i586.rpm
Preparing... (########################################### [100%]
package jdk-1.5.0_12-fcs is already installed
4、將環境變量加入到profile中,如果寫入到(/etc/profile)對所有用戶都生效,如果只對某個用戶生效寫入到(/home/username/profile)中
eXPort JAVA_HOME = /usr/java/jdk1.5
export PATH = $PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
exportCLASSPATH=.:/usr/java/jdk1.5/lib:/usr/java/jdk1.5/jre/lib:$CLASSPATH
5、驗證安裝結果
[root@b java]# java -version
-bash: java: command not found
錯誤原因是環境變量未生效。
[root@b java]# source /etc/profile
[root@b java]# java -version
java version "1.5.0_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode, sharing)
至此安裝成功。
jdk下載地址:http://java.sun.com/javase/downloads/index_jdk5.jsp
Tomcat安裝:
1、將文件copy到/usr/local下解壓安裝文件
[root@b local]# tar -zxvf apache-tomcat-5.5.23.tar.gz
[root@b local]# ls
apache-tomcat-5.5.23 bin games lib man share
apache-tomcat-5.5.23.tar.gz etc include libexec sbin src
[root@b local]# cd ~
2、加入環境變量
[root@b root]# vi .bashrc
export JAVA_HOME=/usr/java/jdk1.5.0_12
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin
export CATALINA_BASE=/usr/local/apache-tomcat-5.5.23
export CATALINA_HOME=/usr/local/apache-tomcat-5.5.23
3、使環境變量生效
[root@b root]# source .bashrc
4、驗證安裝結果
[root@b root]# echo $JAVA_HOME
/usr/java/jdk1.5.0_12
[root@b root]# echo $CATALINA_HOME
/usr/local/apache-tomcat-5.5.23
[root@b root]#