一、描述
在CentOS6.5上使用源代码安装和配置Tomcat7.0.29。
二、安装步骤
1.检查是否已经安装jdk,默认CentOS6.x已经安装了jdk,使用如下命令查看系统是否已经安装jdk
[tong@tong tongSoftware]$ rpm -qa|grep jdk
java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el6_5.x86_64
java-1.6.0-openjdk-1.6.0.0-11.1.13.4.el6.x86_64
显示已经安装jdk,如果系统并未安装jdk,则到oracle官网去下载jdk源码安装包进行安装。
2.使用wget进行下载、解压、重命名
[tong@tong tongSoftware]$ sudo wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.59/bin/apache-tomcat-7.0.59.tar.gz [tong@tong tongSoftware]$ sudo tar xzvf apache-tomcat-7.0.59.tar.gz [tong@tong tongSoftware]$ sudo mv apache-tomcat-7.0.59 tomcat7
3.配置防火墙,开启8080端口,加上如下红色字体标示的行
[tong@tong bin]$ sudo vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
4.重启防火墙
[tong@tong bin]$ service iptables restart
5.启动Tomcat7,进入Tomcat安装目录中的bin目录中执行如下命令:
[tong@tong bin]$ cd /usr/local/tongSoftware/tomcat7/bin/ [tong@tong bin]$ sudo ./startup.sh Using CATALINA_BASE: /usr/local/tongSoftware/tomcat7 Using CATALINA_HOME: /usr/local/tongSoftware/tomcat7 Using CATALINA_TMPDIR: /usr/local/tongSoftware/tomcat7/temp Using JRE_HOME: /usr Using CLASSPATH: /usr/local/tongSoftware/tomcat7/bin/bootstrap.jar:/usr/local/tongSoftware/tomcat7/bin/tomcat-juli.jar Tomcat started.
6.测试Tomcat
在浏览器上输入:http://IP地址:8080,例如我的是:http://192.168.13.110:8080,显示如下界面: