CENT-OS安装jdk1.6和Tomcat
1.》分别下载JDK1.6包和Tomcat包如:jdk-6u25-linux-x64.bin和apache-tomcat-6.0.33.tar.gz
2》.安装JD
1. 以root身份登录系统
2.转到文件夹/usr下,cd /usr。新建文件夹java mkdir java,安装文件用samba拷贝到/usr/java下:
3.通过chmod +x jdk-6u7-linux-i586.bin命令使其获得可执行权限
4.通过 ./jdk-6u7-linux-i586.bin来进行安装
5.安装完毕,JDK安装在/usr/java/目录下
6.设置环境变量(写入/etc/profile中)
vi /etc/profile
文件修改如下,红色字部分为需要修改部分
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
# Path manipulation
#if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
#fi
pathmunge /usr/X11R6/bin after
unset pathmunge
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi
JAVA_HOME=/usr/java/jdk1.6.0_07
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME CLASSPATH
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
unset i
export G_BROKEN_FILENAMES=true
7.保存后执行以下命令:
进入 /usr/bin/目录
cd /usr/bin
ln -s -f /usr/java/jdk1.6.0_20/jre/bin/java
ln -s -f /usr/java/jdk1.6.0_20/bin/javac
8. 在命令行输入
java -version
屏幕输出:
java version "jdk1.6.0_20"
Java(TM) 2 Runtime Environment, Standard Edition (build jdk1.6.0_20)
Java HotSpot(TM) Client VM (build jdk1.6.0_20, mixed mode)
3》安装tomcat
安装tomcat
下载apache-tomcat-5.5.29.tar.gz
2)#tar -zxvf apache-tomcat-5.5.29.tar.gz ;//解压
3)#cp -R apache-tomcat-5.5.29 /usr/local/tomcat ;//拷贝apache-tomcat-5.5.29到/usr/local/下并重命名为tomcat
4) /usr/local/tomcat/bin/startup.sh; //启动tomcat
显示 Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TEMDIR: /usr/local/tomcat/temp
Using JAVA_HOME: /usr/java/jdk1.6.0_20
到此tomcat已经安装完成,现在使用浏览器访问 http://localhost:8080,出现tomcat默认页面,说明已经安装成功。