Linux tomcat的安装配置
下载 & 解压 & 配置环境变量
- 下载
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.22export 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/binbach@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
bach@budy:~/javaweb/apache-tomcat-9.0.22/bin$ catalina.sh --help
Using CATALINA_BASE: /home/bach/javaweb/apache-tomcat-9.0.22
Using CATALINA_HOME: /home/bach/javaweb/apache-tomcat-9.0.22
Using CATALINA_TMPDIR: /home/bach/javaweb/apache-tomcat-9.0.22/temp
Using JRE_HOME: /usr/lib/java/jdk1.8.0_221/jre
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
Usage: catalina.sh ( commands ... )
commands:
debug Start Catalina in a debugger
debug -security Debug Catalina with a security manager
jpda start Start Catalina under JPDA debugger
run Start Catalina in the current window
run -security Start in the current window with security manager
start Start Catalina in a separate window
start -security Start in a separate window with security manager
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
configtest Run a basic syntax check on server.xml - check exit code for result
version What version of tomcat are you running?
Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined
还没有评论,来说两句吧...