时间:2021-04-02 09:47:08 | 栏目:Tomcat | 点击:次
1.检查java版本信息
#java -version java version "1.7.0_65" OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-x86_64 u65-b17) OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
如果没有则安装,则安装jdk
1.1、(以下方式强烈不建议,因为有时候会缺少jar包,导致tomcat启动不成功):
yum -y install java-1.7.0-openjdk
1.2、强烈建议安装oracle的jdk包,此处安装jdk7,到如下网站下载:http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk7-downloads-1880260.html
下载:jdk-7u79-linux-x64.tar.gz到/tmp
解压:tar xzf jdk-7u79-linux-x64.tar.gz
移动:mv jdk1.7.0_79 /usr/local/java
添加环境变量 vim /etc/profile
,在文件末尾添加:
export JAVA_HOME=/usr/local/java export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
立马生效:source /etc/profile
2. 下载并解压缩tomcat
# cd /tmp # wget http://apache.fayea.com/tomcat/tomcat-7/v7.0.72/bin/apache-tomcat-7.0.72.tar.gz # tar xzf apache-tomcat-7.0.72.tar.gz # mv apache-tomcat-7.0.72 /usr/local/tomcat7
3. 启动tomcat
# cd /usr/local/tomcat7 # ./bin/startup.sh
如果以上命令不行,则进入bin文件夹运行 sh startup.sh
[输出样例]
Using CATALINA_BASE: /usr/local/tomcat7 Using CATALINA_HOME: /usr/local/tomcat7 Using CATALINA_TMPDIR: /usr/local/tomcat7/temp Using JRE_HOME: /usr/local/java Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar Tomcat started.
4. 访问http://ip:8080
5. 设置用户账户(可暂时忽略)
<role rolename="admin-gui"/> <role rolename="admin-script"/> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
6. 重启tomcat服务,进入/usr/local/tomcat7目录
# ./bin/shutdown.sh # ./bin/startup.sh
如果以上命令不行,则进入bin文件夹运行 sh shutdown.sh
或者 sh startup.sh
总结
以上就是在CentOS系统下安装Tomcat7的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。