2

mac下安装tomcat9

下载

wget https://mirror.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.31/bin/apache-tomcat-9.0.31.tar.gz

我是在tuna下载的压缩包。
当然,你可以选择在tomcat官网下载,不过有时可能不稳定。
2020-03-16-16-01-03.png

安装&测试

解压

tar -zxvf apache-tomcat-9.0.31.tar.gz

配置server.xml

vim conf/server.xml

搜索8080,找到此connector节点,并增加attribute:URIEncoding="UTF-8",统一字符集,避免出现乱码。

<Connector port="8080" protocol="HTTP/1.1"
                 connectionTimeout="20000"
                 redirectPort="8443" URIEncoding="UTF-8" />

启动tomcat并测试

进入bin目录下输入./startup.sh。看到返回该信息后代表启动成功。
2020-03-16-16-11-00.png
输入ifconfig查看ip地址,并在浏览器中查看效果。
2020-03-16-16-12-43.png
至此,完成tomcat的安装和简单配置。

附加

最后附上一些常用的tomcat命令

// 查看所有的tomcat
ps -ef | grep tomcat 
// 杀死tomcat进程
kill -9 进程号 删除进程
// 重启tomcat
sh bin/startup.sh
// 关闭tomcat
sh bin/shutdown.sh
// 查看tomcat启动日志
tail -f logs/catalina.out -n 200

smartboy
16 声望3 粉丝

您好,世界!