一、今天需要使用到本地的Tomcat,结果在网上找了下教程,都是假的,都有问题,都没有经过测试,不负责任啊啊啊,坑爹坑爹。
Mac正确安装Tomcat的姿势
首先访问一下Tomcat的官网:
Tomcat官网
想下载什么版本就点击什么版本
二、下面以Tomcat9为例,Mac和Linux的一定要下载tar.gz文件,其余的都有问题
三、解压后,重命名文件夹
四、通过终端进入到Tomcat的bin目录下
~/Develop/Tomcat/tomcat9/bin ⌚ 19:16:26
$ pwd
/Users/wangdong/Develop/Tomcat/tomcat9/bin
~/Develop/Tomcat/tomcat9/bin ⌚ 19:16:29
$ ls
bootstrap.jar setclasspath.bat
catalina-tasks.xml setclasspath.sh
catalina.bat shutdown.bat
catalina.sh shutdown.sh
ciphers.bat startup.bat
ciphers.sh startup.sh
commons-daemon-native.tar.gz tomcat-juli.jar
commons-daemon.jar tomcat-native.tar.gz
configtest.bat tool-wrapper.bat
configtest.sh tool-wrapper.sh
daemon.sh version.bat
digest.bat version.sh
digest.sh
~/Develop/Tomcat/tomcat9/bin ⌚ 19:16:31
$
五、启动Tomcat
./startup.sh
~/Develop/Tomcat/tomcat9/bin ⌚ 19:16:31
$ ./startup.sh
Using CATALINA_BASE: /Users/wangdong/Develop/Tomcat/tomcat9
Using CATALINA_HOME: /Users/wangdong/Develop/Tomcat/tomcat9
Using CATALINA_TMPDIR: /Users/wangdong/Develop/Tomcat/tomcat9/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
Using CLASSPATH: /Users/wangdong/Develop/Tomcat/tomcat9/bin/bootstrap.jar:/Users/wangdong/Develop/Tomcat/tomcat9/bin/tomcat-juli.jar
Tomcat started.
~/Develop/Tomcat/tomcat9/bin ⌚ 19:17:23
$
六、访问http://localhost:8080/
出现上述的界面,就证明成功了。
七、关闭Tomcat
./shutdown.sh
~/Develop/Tomcat/tomcat9/bin ⌚ 19:17:23
$ ./shutdown.sh
Using CATALINA_BASE: /Users/wangdong/Develop/Tomcat/tomcat9
Using CATALINA_HOME: /Users/wangdong/Develop/Tomcat/tomcat9
Using CATALINA_TMPDIR: /Users/wangdong/Develop/Tomcat/tomcat9/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
Using CLASSPATH: /Users/wangdong/Develop/Tomcat/tomcat9/bin/bootstrap.jar:/Users/wangdong/Develop/Tomcat/tomcat9/bin/tomcat-juli.jar