系统环境(精简安装,安装过程略):
[root@bogon ~]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.9 (Final)
Release: 5.9
Codename: Final
Tomcat
版本:6.0.18
下载地址:
JDK(JAVA开发环境)
版本:1.6 (实际上就是JAVA6,各位可以查看关于)
下载地址:
jdk有两个版本,个人较喜欢二进制包,可以随便指定安装目录
jdk-6u45-linux-x64.bin ---二进制包
jdk-6u45-linux-x64-rpm.bin ---rpm包
安装配置过程
如果有安装自带的java和tomcat之类的,首先要卸载掉
1.安装tomcat
[root@bogon ~]# ls
apache-tomcat-6.0.18.tar.gz jre-6u45-linux-x64.bin sunwill_web.zip
jdk-6u45-linux-x64.bin jre-6u45-linux-x64-rpm.bin tengine-2.0.2.tar.gz
jdk-6u45-linux-x64-rpm.bin sunwill.sql
[root@bogon ~]# tar -xf apache-tomcat-6.0.18.tar.gz -C /opt/
[root@bogon ~]# cd /opt/
[root@bogon opt]# ln -s apache-tomcat-6.0.18 tomcat
2.安装jdk
[root@bogon ~]# cp jdk-6u45-linux-x64.bin /opt/
[root@bogon ~]# cd /opt/
[root@bogon opt]# chmod u+x jdk-6u45-linux-x64.bin
[root@bogon opt]# ./jdk-6u45-linux-x64.bin
[root@bogon opt]# ln -s jdk1.6.0_45 jdk
[root@bogon opt]# ls -al
total 70548
drwxr-xr-x 7 root root 4096 May 23 21:10 .
drwxr-xr-x 24 root root 4096 May 23 20:14 ..
drwxr-xr-x 9 root root 4096 May 23 20:33 apache-tomcat-6.0.18
lrwxrwxrwx 1 root root 11 May 23 21:10 jdk -> jdk1.6.0_45
drwxr-xr-x 8 root root 4096 Mar 27 2013 jdk1.6.0_45
-rwxr--r-- 1 root root 72087592 May 23 21:09 jdk-6u45-linux-x64.bin
lrwxrwxrwx 1 root root 20 May 23 20:36 tomcat -> apache-tomcat-6.0.18
安装这两个软件时都创建了软链接,只是为了方便以后进行软件升级而已,如果使用新版本的jdk,直接将软连接链接到新版本目录即可
3.配置jdk和tomcat的环境变量
首先配置jdk的环境变量
[root@bogon opt]# vim /etc/profile.d/jdk.sh
export JAVA_HOME=/opt/jdk
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
配置tomcat的环境变量
[root@bogon opt]# vim /etc/profile.d/tomcat.sh
export TOMCAT_HOME=/opt/tomcat
export CATALINA_HOME=/opt/tomcat
export CATALINA_BASE=/opt/tomcat
export CATALINA_TMPDIR=/opt/tomcat/temp
配置完所有的环境变量后,使变量生效
[root@bogon opt]# source /etc/profile
环境变量配置成功的话,可以查看java的版本信息
[root@localhost ~]# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
4.配置tomcat启动脚本
[root@bogon opt]# cp /opt/tomcat/bin/catalina.sh /etc/init.d/tomcat
[root@bogon opt]# chmod u+x /etc/init.d/tomcat
如果没有完成第3步的环境变量并使之生效的话,在启动脚本时会出现如下错误
[root@bogon opt]# /etc/init.d/tomcat
Cannot find /etc/bin/setclasspath.sh
This file is needed to run this program
如果环境变量配置正确的话,显示信息如下
[root@bogon opt]# /etc/init.d/tomcat
Using CATALINA_BASE: /opt/tomcat
Using CATALINA_HOME: /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME: /opt/jdk
Usage: catalina.sh ( commands ... )
commands:
debug Start Catalina in a debugger
debug -security Debug Catalina with a security manager
jpda start Start Catalina under JPDA debugger
run Start Catalina in the current window
run -security Start in the current window with security manager
start Start Catalina in a separate window
start -security Start in a separate window with security manager
stop Stop Catalina
stop -force Stop Catalina (followed by kill -KILL)
version What version of tomcat are you running?
现在正式启动tomcat程序
[root@bogon opt]# /etc/init.d/tomcat start
Using CATALINA_BASE: /opt/tomcat
Using CATALINA_HOME: /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME: /opt/jdk
检测是否成功启动tomcat
[root@bogon opt]# netstat -ntpul | grep 8080
tcp 0 0 :::8080 :::* LISTEN 10180/java
另外使用浏览器访问本机的8080端口,如果能正常显示以下页面,也表示Tomcat运行正常
阅读(1865) | 评论(0) | 转发(0) |