首先已经安装完JDK
1.下载apache-tomcat-7.0.57.tar.gz
2.复制到/opt 解压
[root@iZ2873rjubzZ opt]# cp /root/apache-tomcat-7.0.57.tar.gz /opt/ [root@iZ2873rjubzZ opt]# tar -xzvf apache-tomcat-7.0.57.tar.gz
3. 设置环境变量
[root@iZ2873rjubzZ opt]# vi /etc/profile ##shift+g定位到文件末尾,添加以下代码 export CATALINA_HOME=/opt/apache-tomcat-7.0.57
export JAVA_HOME PATH CLASSPATH
##执行以下命令让配置文件生效
[root@iZ2873rjubzZ opt]# source /etc/profile
4.启动tomcat
[root@iZ2873rjubzZ opt]# apache-tomcat-7.0.57/bin/startup.sh Using CATALINA_BASE: /opt/apache-tomcat-7.0.57 Using CATALINA_HOME: /opt/apache-tomcat-7.0.57 Using CATALINA_TMPDIR: /opt/apache-tomcat-7.0.57/temp Using JRE_HOME: /opt/jdk1.7.0_51 Using CLASSPATH: /opt/apache-tomcat-7.0.57/bin/bootstrap.jar:/opt/apache-t omcat-7.0.57/bin/tomcat-juli.jar Tomcat started.
通过http://localhost:8080 访问有没有启动成功
5. 关闭tomcat
[root@iZ2873rjubzZ opt]# apache-tomcat-7.0.57/bin/shutdown.sh Using CATALINA_BASE: /opt/apache-tomcat-7.0.57 Using CATALINA_HOME: /opt/apache-tomcat-7.0.57 Using CATALINA_TMPDIR: /opt/apache-tomcat-7.0.57/temp Using JRE_HOME: /opt/jdk1.7.0_51 Using CLASSPATH: /opt/apache-tomcat-7.0.57/bin/bootstrap.jar:/opt/apache-t omcat-7.0.57/bin/tomcat-juli.jar [root@iZ2873rjubzZ opt]#
6 设置开启启动
进入编辑 vi /etc/rc.d/rc.local 打开后在最底部复制下面 export JDK_HOME=/opt/jdk1.7.0_51 export JAVA_HOME=/opt/jdk1.7.0_51 /opt/apache-tomcat-7.0.57/bin/startup.sh
7.添加tomcat管理用户
[root@dev ~]# vi /opt/apache-tomcat-7.0.57/conf/tomcat-users.xml 最下面添加 <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user username="tomcat" password="s3cret" roles="manager-gui,manager-jmx,manager-script,manager-status"/>
8.增大tomcat 启动内存
打开文件 [root@dev ~]# vi /opt/apache-tomcat-7.0.57/bin/catalina.sh 注释下的第一行 添加 JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=512m"
至此 tomcat已经安装完成