Linux安装部署Tomcat

2024-04-25 20:20:40 浏览数 (1)

Linux安装部署Tomcat

  • //将tomcat压缩包解压到对应目录
代码语言:javascript复制
tar zxvf apache-tomcat-8.5.100.tar.gz -C /usr/local/tomcat
  • //新建setenv.sh文件
代码语言:javascript复制
touch /usr/local/tomcat/apache-tomcat-8.5.100/bin/setenv.sh
  • //修改setenv.sh文件
代码语言:javascript复制
vi /usr/local/tomcat/apache-tomcat-8.5.100/bin/setenv.sh
  • //tomcat:setenv.sh配置
代码语言:javascript复制
# 需要事先安装好JDK,可自行上网找教程
JAVA_HOME=/usr/local/jdk1.8.0_351

CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.5.100

CATALINA_PID=/usr/local/tomcat/apache-tomcat-8.5.100/bin/tomcat.pid

JAVA_OPTS="-server-Dfile.encoding=UTF-8 -Xms4096m -Xmx4096m-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
  • //修改端口为8083(选做)
代码语言:javascript复制
sed -i "s/8080/8083/g" /usr/local/tomcat/apache-tomcat-8.5.100/conf/server.xml
  • //增加tomcat静态资源缓存(<Resources cachingAllowed="true" cacheMaxSize="262144"/>)
代码语言:javascript复制
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
    #新增的配置
    <Resources cachingAllowed="true" cacheMaxSize="262144"/>
  • //启停tomcat,查看日志
代码语言:javascript复制
# 启动tomcat
/usr/local/tomcat/apache-tomcat-8.5.100/bin/startup.sh
# 或者
cd /usr/local/tomcat/apache-tomcat-8.5.100/bin
./startup.sh

# 停止tomcat
/usr/local/tomcat/apache-tomcat-8.5.100/bin/shutdown.sh
# 或者
cd /usr/local/tomcat/apache-tomcat-8.5.100/bin
./shutdown.sh

# 查看日志
tail -f /usr/local/tomcat/apache-tomcat-8.5.100/logs/catalina.out

0 人点赞