当前位置: > Linux服务器 > Tomcat >

CentOS7 Tomcat安装

时间:2015-04-21 19:03来源:linux.it.net.cn 作者:IT网

CentOS7 Tomcat安装

Download

  • 从Tomcat下载apache-tomcat-8.0.18.tar.gz

Install

  • 安装

上传RPM文件到/tmp目录下

mkdir /opt/tomcat
cd /opt/tomcat
tar -zxvf /tmp/apache-tomcat-8.0.18.tar.gz
ln -sf /opt/tomcat/apache-tomcat-8.0.18/opt/tomcat/latest
ln -sf /opt/tomcat/latest /opt/tomcat/default

将以下设定加入/opt/tomcat/default/conf/tomcat-users.xml

<rolerolename="manager-gui"/>
<userusername="manager"password="manager"roles="manager-gui"/>

新建用户

useradd -r tomcat --shell /bin/false
chown -hR tomcat:/opt/tomcat
  • 开机启动

jsvc解压

cd /opt/tomcat/default/bin
tar zxvf commons-daemon-native.tar.gz
cd commons-daemon-1.0.15-native-src/unix/
./configure
make
cp jsvc ../..

新建/etc/init.d/tomcat

#!/bin/sh

# chkconfig: - 80 20
# Description: Tomcat

CATALINA_HOME=/opt/tomcat/default
TOMCAT_USER=tomcat
JAVA_HOME=/usr/java/default

"$CATALINA_HOME/bin/daemon.sh"\
--java-home "$JAVA_HOME"\
--catalina-home "$CATALINA_HOME"\
--tomcat-user "$TOMCAT_USER"\
$1
exit $?

赋予执行权限

chmod +x /etc/init.d/tomcat

设定开机启动

chkconfig tomcat on
  • 防火墙

新建文件/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


(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容