原文地址 http://www.centoscn.com/image-text/install/2015/0311/4859.html
centos7安装tomcat7的步骤如下:
1.下载tomcat7的tar.gz文件,并解压缩到/usr/local目录
- $>tar -zxvf apache-tomcat-7.0.59.tar.gz -C /usr/local
- $> mv apache-tomat-7.0.59 tomcat7
- $> cd /usr/local/tomcat7/bin
- $>tar -zxvf commons-daemon-native.tar.gz
- $>cd commons-daemon-native.src/unix
- $>./configure
- $>make
make后,会在当前文件夹下生成一个名为 jsvc 的文件,将其复制到$CATALINA_HOME/bin目录
- $>cp jsvc ../../
- $>useradd tomcat -M -d / -s /usr/sbin/nologin
4.回到$CATALINA_HOME/bin目录下
- $> cd /usr/local/tomcat7/bin
- $>vi daemon.sh
- # chkconfig: - 85 15
- export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_31
- export CATALINA_HOME=/usr/local/tomcat7
- ARG0="/usr/local/tomcat7"
- TOMCAT_USER=tomcat,JAVA_HOME=/usr/lib/jvm/jdk1.8.0_31
- $> chmod +x *.sh
- $>chown -R tomcat:tomcat /usr/local/tomcat7
- $> ln -s /usr/local/tomcat7/bin/daemon.sh /etc/init.d/tomcat7
- $> chkconfig --add tomcat7
- $>chkconfig --level 2345 tomcat7 on
- $>service tomcat7 start
新建文件/usr/lib/firewalld/services/tomcat.xml,内容为:
- <?xml version="1.0" encoding="utf-8"?>
- <service>
- <short>Tomcat</short>
- <description>Apache Tomcat Web Application Container</description>
- <portprotocol="tcp"port="8080"/>
- </service>
- firewall-cmd --permanent --add-service=tomcat
- firewall-cmd --reload