linux部署tomcat

安装说明

安装环境:CentOS-6.5
安装方式:源码安装 
软件:apache-tomcat-6.0.45.tar.gz
下载地址:http://tomcat.apache.org/download-60.cgi

安装前提

系统必须已经安装配置了JDK8+,如果不会安装请参考《CentOS-6.5安装配置JDK-8》。

安装tomcat

将apache-tomcat-6.0.45.tar.gz文件上传到/usr/local中执行以下操作:

[root@admin local]# cd /usr/local
[root@admin local]# tar -zxv -f apache-tomcat-6.0.45.tar.gz         // 解压压缩包 
[root@admin local]# rm -rf apache-tomcat-6.0.45.tar.gz   // 删除压缩包 
[root@admin local]# mv apache-tomcat-6.0.45.tar.gz  tomcat

启动Tomcat

执行以下操作:

[root@admin ~]#  /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.8.0_101
/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

出现以上的打印信息说明已经成功启动。

防火墙开放8080端口

增加8080端口到防火墙配置中,执行以下操作:

[root@admin ~]# vi + /etc/sysconfig/iptables
#增加以下代码 
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

重启防火墙

[root@admin java]# service iptables restart

检验Tomcat安装运行

通过以下地址查看tomcat是否运行正常:

http://192.168.15.231:8080/

看到tomcat系统界面,恭喜,安装成功!停止Tomcat

[root@admin ~]#  /usr/local/tomcat/bin/shutdown.sh   //停止tomcat

tomcat启动文件

[root@web-server ~]# cat /etc/init.d/tomcatd

#!/bin/bash
# tomcat-server Startup script for the Apache tomcat Server
# chkconfig: -
# description: The Apache HTTP Server is an efficient and extensible \
# server implementing the current HTTP standards.
# processname: httpd
# config:
# config:
# pidfile: /var/run/tomcatd.pid
#
startup="/usr/local/web-tomcat/bin/startup.sh"
shutdown="/usr/local/web-tomcat/bin/shutdown.sh"
. /etc/rc.d/init.d/functions
start() {
echo -e " tomcat-Server" "\e[1;32m starting :ok \e[0m"
$startup > /dev/null
} stop() {
echo -e " tomcat-Server" "\e[1;32m stopting :ok \e[0m"
$shutdown > /dev/null
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
_p=`ps -ef | grep startup | grep -v "grep" | wc -l`
if [ $_p -eq ];then
echo "running"
else
echo "stopting"
fi
;;
restart)
stop
start
;;
esac exit $RETVAL

启动文件

开机自启动

[root@web-server ~]# chkconfig tomcatd on 
上一篇:Oracle客户端安装及配置


下一篇:JavaScript可以这样用