Linux tomcat的安装配置

电玩女神 2021-11-11 06:14 368阅读 0赞

下载 & 解压 & 配置环境变量

  • 下载
    http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.22/bin/apache-tomcat-9.0.22.tar.gz
  • 解压至指定文件夹(需提前创建好目标文件夹,我的:mkdir ~/javaweb)
    tar -zxvf apache-tomcat-9.0.22.tar.gz -C ~/javaweb/
  • 配置环境变量
    编辑~/.bashrc,在最后添加:

    tomcat环境变量

    export CATALINE_HOME=/home/bach/javaweb/apache-tomcat-9.0.22
    export CATALINE_BASE=/home/bach/javaweb/apache-tomcat-9.0.22

    export PATH=${CATALINE_HOME}/bin:$PATH

  • 重新执行配置文件中的命令(更新最新配置)。
    source ~/.bashrc

  • 测试环境变量是否配置成功。
    echo $CATALINE_HOME
    echo $PATH

tomcat运行测试

  • $CATALINE_HOME/bin目录下的命令

    bach@budy:~/javaweb/apache-tomcat-9.0.22/bin$ pwd
    /home/bach/javaweb/apache-tomcat-9.0.22/bin

    bach@budy:~/javaweb/apache-tomcat-9.0.22/bin$ ls
    bootstrap.jar ciphers.bat configtest.bat digest.sh setclasspath.sh startup.sh tool-wrapper.sh
    catalina.bat ciphers.sh configtest.sh makebase.bat shutdown.bat tomcat-juli.jar version.bat
    catalina.sh commons-daemon.jar daemon.sh makebase.sh shutdown.sh tomcat-native.tar.gz version.sh
    catalina-tasks.xml commons-daemon-native.tar.gz digest.bat setclasspath.bat startup.bat tool-wrapper.bat

有两种启动和停止方式:

  • 运行startup.sh启动,运行shutdown.sh关闭服务器。
  • 运行cataline.sh加选项。

    run Start Catalina in the current window
    start Start Catalina in a separate window
    stop Stop Catalina, waiting up to 5 seconds for the process to end
    stop n Stop Catalina, waiting up to n seconds for the process to end
    stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
    stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running
    version What version of tomcat are you running?

catalina.sh run 启动服务器(直接在当前窗口运行) 不推荐
catalina.sh start 启动服务器(新开一个窗口/后台运行)
catalina.sh stop 停止catalina服务器。
当远程登录时,只有一个shell界面,建议使用catalina.sh start启动服务器。

  • 运行测试
    启动服务器:catalina.sh start
    浏览器访问地址:localhost:8080,如下图:
    在这里插入图片描述停止服务器:catalina.sh stop,再次访问浏览器:
    在这里插入图片描述- Shell命令截图
    在这里插入图片描述

Others

  1. bach@budy:~/javaweb/apache-tomcat-9.0.22/bin$ catalina.sh --help
  2. Using CATALINA_BASE: /home/bach/javaweb/apache-tomcat-9.0.22
  3. Using CATALINA_HOME: /home/bach/javaweb/apache-tomcat-9.0.22
  4. Using CATALINA_TMPDIR: /home/bach/javaweb/apache-tomcat-9.0.22/temp
  5. Using JRE_HOME: /usr/lib/java/jdk1.8.0_221/jre
  6. Using CLASSPATH: /home/bach/javaweb/apache-tomcat-9.0.22/bin/bootstrap.jar:/home/bach/javaweb/apache-tomcat-9.0.22/bin/tomcat-juli.jar
  7. Usage: catalina.sh ( commands ... )
  8. commands:
  9. debug Start Catalina in a debugger
  10. debug -security Debug Catalina with a security manager
  11. jpda start Start Catalina under JPDA debugger
  12. run Start Catalina in the current window
  13. run -security Start in the current window with security manager
  14. start Start Catalina in a separate window
  15. start -security Start in a separate window with security manager
  16. stop Stop Catalina, waiting up to 5 seconds for the process to end
  17. stop n Stop Catalina, waiting up to n seconds for the process to end
  18. stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
  19. stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running
  20. configtest Run a basic syntax check on server.xml - check exit code for result
  21. version What version of tomcat are you running?
  22. Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined

发表评论

表情:
评论列表 (有 0 条评论,368人围观)

还没有评论,来说两句吧...

相关阅读