CentOS7 Tomcat安装
Download
- 从Tomcat下载apache-tomcat-8.0.18.tar.gz
Install
- 安装
上传RPM文件到/tmp目录下
mkdir /opt/tomcatcd /opt/tomcattar -zxvf /tmp/apache-tomcat-8.0.18.tar.gzln -sf /opt/tomcat/apache-tomcat-8.0.18/opt/tomcat/latestln -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/falsechown -hR tomcat:/opt/tomcat
- 开机启动
jsvc解压
cd /opt/tomcat/default/bintar zxvf commons-daemon-native.tar.gzcd commons-daemon-1.0.15-native-src/unix/./configuremakecp jsvc ../..
新建/etc/init.d/tomcat
#!/bin/sh # chkconfig: - 80 20# Description: Tomcat CATALINA_HOME=/opt/tomcat/defaultTOMCAT_USER=tomcatJAVA_HOME=/usr/java/default "$CATALINA_HOME/bin/daemon.sh"\--java-home "$JAVA_HOME"\--catalina-home "$CATALINA_HOME"\--tomcat-user "$TOMCAT_USER"\$1exit $?
赋予执行权限
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=tomcatfirewall-cmd --reload
时间: 2024-12-19 07:35:01