环境要求:
系统:
[root@Wulaoer ~]# cat /proc/version
Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013
安装方式源码安装
软件:apache-tomcat-8.0.0.RC3.tar.gz
需求:必须安装jdk
[root@Wulaoer ~]# java -version
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
软件下载:
[root@Wulaoer ~]# wget http://124.205.69.166/files/917300000333E604/mirrors.noc.im/apache/tomcat/tomcat-8/v8.0.32/bin/apache-tomcat-8.0.32.tar.gz
[root@Wulaoer ~]# tar -zxf apache-tomcat-8.0.32.tar.gz
[root@Wulaoer ~]# mkdir /usr/local/tomcat
[root@Wulaoer ~]# cp -a apache-tomcat-8.0.32/* /usr/local/tomcat/
安装tomcat
[root@Wulaoer~]# /usr/local/tomcat/bin/startup.sh
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.8.0_73/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
安装成功,防火墙开放8080端口,增加到防火墙配置中,
[root@Wulaoer ~]# /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
[root@Wulaoer ~]# /etc/rc.d/init.d/iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定]
[root@Wulaoer ~]# /etc/rc.d/init.d/iptables restart
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]
iptables:应用防火墙规则: [确定]
关闭tomcat用:
[root@Wulaoer~]# /usr/local/tomcat/bin/shutdown.sh
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.8.0_73/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
防火墙配置完成,检验以下测试运行
测试成功。
设置Tomcat的开机自启动,在/etc/rc.d/rc.local的底部添加下面内容。
[root@Wulaoer ~]# vi /etc/rc.d/rc.local
touch /var/lock/subsys/local
export JDK_HOME=/usr/java/jdk1.8.0_73
export JAVA_HOME=/usr/java/jdk1.8.0_73
/usr/local/tomcat/bin/startup.sh
注意:jdk的路径和tomcat的路径要根据自己安装的路径。重启以下测试。
熟悉以下tomcat的配置文件。
查看以下/usr/local/tomcat/conf/server.xml文件。
例如把8080端口修改成80端口。
[root@Wulaoer ~]# vi /usr/local/tomcat/conf/server.xml
在文件里找到,
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
把8080修改程80,保存重启以下tomcat,直接访问测试。