1.查看CentOS自带的JDK是否安装,如果已经安装卸载
#rpm –qa | grep jdk
#rpm –qa | grep gcj
#yum –y remove java-*-gcj-comat
2.安装JDK
下载jdk-6u18-linux-i586.bin或者jdk-6u18-linux-i586-rpm.bin,本次安装使用jdk-6u18-linux-i586.bin
#mkdir /usr/local/java
#cd .usr/local/java
#chmod +x jdk-6u18-linux-i586.bin
#./jdk-6u18-linux-i586.bin
选择YES
3.配置环境变量
#vi /etc/profile
在最后加入以下几行
export JAVA_HOME=/usr/local/java/jdk1.6.0_18
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
4.#reboot
5.检查
[root@nagios conf]# echo $JAVA_HOME
/usr/local/java/jdk1.6.0_18
[root@nagios conf]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/java/jdk1.6.0_18/bin:/root/bin
[root@nagios conf]# echo $CLASSPATH
.:/usr/local/java/jdk1.6.0_18/jre/lib/rt.jar:/usr/local/java/jdk1.6.0_18/lib/dt.jar:/usr/local/java/jdk1.6.0_18/lib/tools.jar
[root@nagios conf]# java -version
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)
6.下载tomcat
#tar –zxvf apache-tomcat-6.0.18.tar.gz
#mv apache-tomcat-6.0.18 /usr/local/tomcat
启动tomcat
[root@nagios conf]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/java/jdk1.6.0_18
默认访问http://localhost:8080,出现默认页面,说明安装成功
注册自己的项目,放到/usr/local/tomcat/webapps
把短信机发送程序sms.war放在 /usr/local/tomcat/webapps
修改默认端口可以在/usr/localtomcat/conf/server.xml中
关闭tomcat
[root@nagios conf]# /usr/local/tomcat/bin/shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/java/jdk1.6.0_18
#vi /etc/rc.d/rc.local
JAVA_HOME=/usr/local/java/jdk1.6.0_18
export JAVA_HOME
/usr/local/tomcat/bin/shutdown.sh 开机启动