Tomcat的官方站点为http://tomcat.apache.org/,要安装Tomcat,首先需要安装JDK(linux下安装JDK教程https://94ip.com./post/224.html)。
以下安装平台为CentOS release 6.6 (Final) 32位平台上,JDK 版本为jdk-6u45-linux-i586-rpm.bin ,tomcat 使用 apache-tomcat-7.0.63.tar.gz。
将上述两个文件下载到服务器,然后根据下面命令顺序执行:
具体执行解决现实如下:
[root@localhost tomcat]# ls -l
total 75676
-rw-r--r--. 1 root root 8850470 Aug 12 02:08 apache-tomcat-7.0.63.tar.gz
-rw-r--r--. 1 root root 68637258 Apr 6 2014 jdk-6u45-linux-i586-rpm.bin
[root@localhost tomcat]# chmod +x jdk-6u45-linux-i586-rpm.bin
[root@localhost tomcat]# ./jdk-6u45-linux-i586-rpm.bin
[root@localhost tomcat]# tar xf apache-tomcat-7.0.63.tar.gz -C /usr/local/
[root@localhost tomcat]# ln -s /usr/local/apache-tomcat-7.0.63/ /usr/local/tomcat
[root@node1 tomcat]# vim /etc/profile.d/java.sh #设置java环境变量
export JAVA_HOME=/usr/java/latest
export PATH=$PATH:$JAVA_HOME/bin
[root@node1 conf]# . /etc/profile.d/tomcat.sh
[root@node1 tomcat]# vim /etc/profile.d/tomcat.sh #设置tomcat环境变量
export CATALINA_HOME=/usr/local/tomcat
export PATH=$PATH:$CATALINA_HOME/bin
[root@node1 conf]# catalina.sh version
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.6.0_45
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.63
Server built: Jun 30 2015 08:08:33 UTC
Server number: 7.0.63.0
OS Name: Linux
OS Version: 2.6.32-504.el6.i686
Architecture: i386
JVM Version: 1.6.0_45-b06
JVM Vendor: Sun Microsystems Inc.
[root@localhost tomcat]# vim /etc/init.d/tomcat #提供启动脚本
#!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.
# JAVA_OPTS='-Xms64m -Xmx128m'
JAVA_HOME=/usr/java/latest
CATALINA_HOME=/usr/local/tomcat
export JAVA_HOME CATALINA_HOME
case $1 in
start)
exec $CATALINA_HOME/bin/catalina.sh start ;;
stop)
exec $CATALINA_HOME/bin/catalina.sh stop;;
restart)
$CATALINA_HOME/bin/catalina.sh stop
sleep 2
exec $CATALINA_HOME/bin/catalina.sh start ;;
configtest)
exec $CATALINA_HOME/bin/catalina.sh configtest ;;
*)
exec $CATALINA_HOME/bin/catalina.sh * ;;
esac
[root@localhost tomcat]# chmod +x /etc/init.d/tomcat
[root@localhost tomcat]# chkconfig --add tomcat
[root@node1 tomcat]# catalina.sh start
[root@node1 tomcat]# jps #显示Bootstrap启动则表示启动成功
29145 Bootstrap
29163 Jps
转载请注明:IT运维空间 » Tomcat » linux下安装Tomcat教程
发表评论