在线安装
待补充
离线安装
- 下载
- 安装
上传到服务器,并解压
sudo tar -zxf apache-tomcat-8.0.52.tar.gz -C /opt
- 配置
环境变量配置
## sudo vim /etc/profile ## 所有用户有效
export CATALINA_HOME=/opt/apache-tomcat-8.0.52 ## bin,lib
export CATALINA_BASE=/opt/apache-tomcat-8.0.52 ## conf,logs,webapps,work,temp
export PATH=$PATH:$CATALINA_HOME/bin
alias slg='sudo tail -f $CATALINA_BASE/logs/catalina.out'
#source /etc/profile
tomcat服务器配置
## sudo vim $CATALINA_BASE/conf/logging.properties ## 日志配置
1catalina.org.apache.juli.AsyncFileHandler.formatter = java.util.logging.SimpleFormatter
2localhost.org.apache.juli.AsyncFileHandler.formatter = java.util.logging.SimpleFormatter
3manager.org.apache.juli.AsyncFileHandler.formatter = java.util.logging.SimpleFormatter
4host-manager.org.apache.juli.AsyncFileHandler.formatter = org.apache.juli.OneLineFormatter
# java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter ## 屏蔽
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=%1$tT,%1$tL %4$s [%3$s] - %5$s%6$s%n
sudo vim $CATALINA_BASE/conf/tomcat-users.xml ## 用户
# sudo vim $CATALINA_BASE/conf/server.xml ## 服务器【修改端口为 80/443】
sudo sed -i 's/8080/80/g' $CATALINA_BASE/conf/server.xml
sudo sed -i 's/8443/443/g' $CATALINA_BASE/conf/server.xml
sudo vim $CATALINA_BASE/conf/context.xml ## 站点
## sudo vim $CATALINA_BASE/bin/catalina.sh
JAVA_OPTS="$JAVA_OPTS -Djava.security.egd=file:/dev/./urandom"
JAVA_OPTS="$JAVA_OPTS -XX:+UseParallelOldGC -Xms512M -Xmx512M -Xmn256M -XX:SurvivorRatio=8 -XX:PermSize=64M -XX:MaxPermSize=128M"
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:$CATALINA_BASE/logs/gc.log"
CATALINA_OUT=/dev/null
- 启动Tomcat
也可以使用命令查看tomcat是否启动成功
ps -ef|grep tomcat
- 访问
如果访问不了,需要查看网络是否能通,防火墙是否已拦截了端口8080
如果防火墙拦截了端口,使用命令将防火墙添加到规则中,并重启下防火墙服务
最后访问显示如下