个人简介:Java领域新星创作者;阿里云技术博主、星级博主、专家博主;正在Java学习的路上摸爬滚打,记录学习的过程~
个人主页:.29.的博客
学习社区:进去逛一逛~
Linux安装部署Tomcat
//将tomcat压缩包解压到对应目录
bash
tar zxvf apache-tomcat-8.5.100.tar.gz -C /usr/local/tomcat
//新建setenv.sh文件
bash
touch /usr/local/tomcat/apache-tomcat-8.5.100/bin/setenv.sh
//修改setenv.sh文件
bash
vi /usr/local/tomcat/apache-tomcat-8.5.100/bin/setenv.sh
//tomcat:setenv.sh配置
bash
# 需要事先安装好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(选做)
bash
sed -i "s/8080/8083/g" /usr/local/tomcat/apache-tomcat-8.5.100/conf/server.xml
- //增加tomcat静态资源缓存(
<Resources cachingAllowed="true" cacheMaxSize="262144"/>
)
xml
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
#新增的配置
<Resources cachingAllowed="true" cacheMaxSize="262144"/>
//启停tomcat,查看日志
bash
# 启动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