2021-11-14 15:52:46 +08:00

68 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "Tomcat 笔记"
date: 2019-10-29T21:19:44+08:00
lastmod: 2019-10-29T21:19:44+08:00
keywords: []
tags: ["tomcat", "jdk", "java"]
categories: ["web"]
---
## 部署 jre8
- 下载 oracle jre8[下载界面](https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)
- 解压
```bash
tar zxf jre-8u221-linux-x64.tar.gz -C /opt/
cd /opt && mv jre-8u221-linux jre
```
- 创建 /etc/profile.d/jre.sh内容如下
```bash
export JAVA_HOME=/opt/jre
export PATH=$JAVA_HOME/bin:$PATH
```
## 部署 tomcat8
- 下载 tomcat
```bash
curl -O http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.45/bin/apache-tomcat-8.5.45.tar.gz
```
- 解压
```bash
tar zxf apache-tomcat-8.5.45.tar.gz -C /opt/
cd /opt/ && mv apache-tomcat-8.5.45 tomcat
```
- 创建文件 /opt/tomcat/bin/setenv.sh内容如下
```bash
export JAVA_HOME=/opt/jre
export JAVA_OPTS="$JAVA_OPTS -server -Xms8192M -Xmx8192M -Xmn3072M -Xss512K -Djava.security.egd=file:/dev/./urandom -XX:+DisableExplicitGC -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -Ddruid.registerToSysProperty=true"
# -Djava.library.path=/opt/tomcat/libs/tcnative # tcnative 库位置
#export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=10087"
export CATALINA_PID="/var/run/tomcat.pid"
```
- 创建 /usr/lib/systemd/system/tomcat.service 文件,内容如下
```bash
[Unit]
Description=The Apache Tomcat
After=network.target
[Service]
Type=forking
PIDFile=/var/run/tomcat.pid
ExecStart=/opt/tomcat/bin/catalina.sh start
ExecStop=/opt/tomcat/bin/catalina.sh stop
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
```
- 启动 tomcat 服务
```bash
systemctl daemon-reload
systemctl start tomcat
```
## 验证码字体
```bash
yum install dejagnu dejavu-sans-mono-fonts dejavu
```