一、下载 tomcat
下载最新版的tomcat
cd /usr/local/src
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.50/bin/apache-tomcat-7.0.59.tar.gz
二、解压安装 tomcat
tar zxvf apache-tomcat-7.0.59.tar.gz
mv apache-tomcat-7.0.59.tar.gz tomcat7
三、配置环境变量
vi /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64
export JRE_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
cd /usr/local/tomcat7/bin
vi catalina.sh
#!/bin/sh
export TOMCAT_HOME=/usr/local/tomcat7
export CATALINA_HOME=/usr/local/tomcat7
利用下面命令使文件有执行权限并使配置生效
# source /etc/profile
# cd /usr/local/tomcat7/bin
# chmod 777 *.*
四、配置tomcat
(1)将tomcat加入开机自启动
echo "source /etc/profile" >>/etc/rc.d/rc.local
echo "/usr/local/tomcat1/bin/startup.sh" >>/etc/rc.d/rc.local
这里有点要说明,rc.local先于/etc/profile执行,所以会得不到JAVA环境变量,
所以在startup.sh前加入代码:source /etc/profile 这样就可以
五、测试
# cd /usr/local/tomcat1/bin
# ./startup.sh 如下 显示正常
本文出自 “Linux is belong to you” 博客,请务必保留此出处http://jwh5566.blog.51cto.com/7394620/1629113
原文地址:http://jwh5566.blog.51cto.com/7394620/1629113