安装配置tomcat
1:在http://tomcat.apache.org/download-80.cgi下载最新安装包
2:安装tomcat
将apache-tomcat-8.0.21.tar.gz文件上传到/usr/local中执行以下操作:(此路径可变)
复制代码
代码如下:
[[email protected] local]# cd /usr/local
[[email protected] local]# tar -zxvf apache-tomcat-8.0.21.tar.gz // 解压压缩包
[[email protected] local]# rm -rf apache-tomcat-8.0.21.tar.gz // 删除压缩包
[[email protected] local]# mv apache-tomcat-8.0.21 tomcat //改名为tomcat
然后
Service iptables stop 关闭防火墙
3:启动Tomcat执行以下操作
复制代码
代码如下:
[[email protected] ~]# /usr/local/tomcat/bin/startup.sh //启动tomcat
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.7.0/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
出现以上信息说明已成功启动。
如果出现下面错误:
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
则要注意前提还要设置java路径
在apache-tomcat-8.0.9/bin/setclasspath.sh中添加一下内容
export JAVAHOME=/opt/jdk1.8.0
export JREHOME=/opt/jdk1.8.0/jre
export CLASSPATH=.:$JAVAHOME/lib:$JREHOME/lib:$CLASSPATH
export PATH=$JAVAHOME/bin:$JREHOME/bin:$PATH
防火墙开放8080端口
增加8080端口到防火墙配置中,执行以下操作:
[[email protected] ~]# vi + /etc/sysconfig/iptables
#增加以下代码
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j
ACCEPT
重启防火墙
[[email protected] java]# service iptables restart
检验Tomcat安装运行
通过以下地址查看tomcat是否运行正常:
http://192.168.15.231:8080/
看到tomcat系统界面,说明安装成功!
停止Tomcat
[[email protected] ~]# /usr/local/tomcat/bin/shutdown.sh //停止tomcat
自动启动tomcat服务
vim /etc/rc.local
然后在文本里添加以下内容便可
service iptables stop
export JAVA_HOME=/usr/java/jdk1.8.0_25
/data/soft/tomcat/cap-api/bin/startup.sh
/data/soft/tomcat/cap-crm/bin/startup.sh
/data/soft/tomcat/cap-update/bin/startup.sh