1、官网下载最新的tomcat;
https://tomcat.apache.org/
2、上传tomcat并解压
3、修改内存大小 265行左右
/java/apache-tomcat-9.0.39/bin/catalina.sh
#JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS"
JAVA_OPTS="$JSSE_OPTS -Xmx6144m -Xms6144m -Xmn2456m -Xss3072k -XX:+UseParallelGC"
安全配置
4、更改默认端口8080,优化配置
/java/apache-tomcat-9.0.39/conf/server.xml
<Executor
name="tomcatThreadPool"
namePrefix="catalina-exec-"
maxThreads="500"
minSpareThreads="100"
prestartminSpareThreads="true"
maxQueueSize="100"
/>
<Connector
executor="tomcatThreadPool"
port="8080"
protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
maxConnections="1000"
redirectPort="8443"
enableLookups="false"
acceptCount="100"
maxPostSize="10485760"
acceptorThreadCount="2"
URIEncoding="utf-8"
/>
5、删除webapps下默认所有目录和文件
mv docs docs_1
mv examples examples_1
mv host-manager host-manager_1
mv manager manager_1
mv ROOT ROOT_1
mkdir ROOT
6、自定义错误页
/java/apache-tomcat-9.0.31/conf/web.xml
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>
404.html
<html>
<head>
<title>404</title>
</head>
<body>
<p>404</p>
</body>
</html>
7、取消session的持久化,默认是开启session持久化的
/java/apache-tomcat-9.0.31/conf/context.xml
取消注释
<Manager pathname="" />