今天用到 tomcat,然后发现自己的版本是 8,而最新版本已经是 9 了,想着就用最新的. 卸载了 8 然后悲剧了,一直安装不了,摸了一天鱼,终于搞定了,记录一下!
1.下载 tomcat,发现一直失败
dashudeMacBook-Pro:~ dashu$ brew install tomcat
==> Downloading https://www.apache.org/dyn/closer.cgi?path=/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.tar.gz
==> Downloading from http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.tar.gz
curl: (22) The requested URL returned error: 404 Not Found
Trying a mirror...
==> Downloading https://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.tar.gz
^C^C
dashudeMacBook-Pro:~ dashu$
2.看下了输出,奇怪,为什么国内镜像不行,反而转欧美镜像了(有墙下载不下来很正常啊!)
于是去看下国内镜像,果然,国内镜像确实不存在
- 试着访问了镜像地址:https://www.apache.org/dyn/closer.cgi?path=/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.tar.gz
3.那就按照提示用 9.0.27 版本呗,想着指定 url 下载吧!
结果还是悲剧...百度之,ruby 字符解析问题?(我不会 ruby 语法啊,搞不懂)
dashudeMacBook-Pro:~ dashu$ brew install "https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz"
######################################################################## 100.0%
######################################################################## 100.0%
Error: apache-tomcat-9.0.27.tar.gz: /Users/dashu/Library/Caches/Homebrew/Formula/apache-tomcat-9.0.27.tar.gz:1: Invalid char `\x1F' in expression
/Users/dashu/Library/Caches/Homebrew/Formula/apache-tomcat-9.0.27.tar.gz:1: invalid multibyte char (UTF-8)
4.搜索了半天 ruby “invalid multibyte char”,毫无头绪···.(中间也试了很多其他猜想,不赘述了)
我还真不信了,一直都是通过 homebrew 安装软件的啊.于是想前向不行,后向试试? 试着安装 7,诶!还真行~
dashudeMacBook-Pro:~ dashu$ brew install tomcat7
==> Downloading https://www.apache.org/dyn/closer.cgi?path=tomcat/tomcat-7/v7.0.96/bin/apache-tomcat-7.0.96.tar.gz
==> Downloading from http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.96/bin/apache-tomcat-7.0.96.tar.gz
######################################################################## 100.0%
==> Caveats
tomcat@7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have tomcat@7 first in your PATH run:
echo 'export PATH="/usr/local/opt/tomcat@7/bin:$PATH"' >> ~/.bash_profile
To have launchd start tomcat@7 now and restart at login:
brew services start tomcat@7
Or, if you don't want/need a background service you can just run:
catalina run
==> Summary
🍺 /usr/local/Cellar/tomcat@7/7.0.96: 634 files, 13.6MB, built in 14 seconds
5.到这里,朋友们回觉得:终于安装好 tomcat 了,任务完成!可以继续安心摸鱼···但楼主决不是求安逸的人,一定要搞明白 WHY!
灵机一动,brew 其实运行的是 git 仓库里的 ruby 脚本,这样看来莫不是仓库里的代码不是最新的? 于是 brew update 搞起
dashudeMacBook-Pro:~ dashu$ brew update
fatal: unable to access 'https://github.com/Homebrew/homebrew-cask/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
Updated 1 tap (homebrew/cask-versions).
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home
No changes to formulae.
6.哦吼,问题就是它--更新不了 ruby 脚本!
百度之,やっぱり! 需要将 git 远程仓库地址也修改成国内镜像,解决方案简单,修改之.
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
7.再试一次“brew update”.完美,更新成功
dashudeMacBook-Pro:homebrew-core dashu$ brew update
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
...(其他更新内容太多,就不贴了)
8.见证奇迹的时刻.-)
dashudeMacBook-Pro:homebrew-core dashu$ brew info tomcat
tomcat: stable 9.0.27
Implementation of Java Servlet and JavaServer Pages
https://tomcat.apache.org/
Not installed
From: https://mirrors.ustc.edu.cn/homebrew-core.git/Formula/tomcat.rb
==> Requirements
Required: java >= 1.8 ✔
==> Caveats
To have launchd start tomcat now and restart at login:
brew services start tomcat
Or, if you don't want/need a background service you can just run:
catalina run
==> Analytics
install: 7,501 (30 days), 17,972 (90 days), 72,461 (365 days)
install_on_request: 6,671 (30 days), 16,066 (90 days), 63,395 (365 days)
build_error: 0 (30 days)
dashudeMacBook-Pro:homebrew-core dashu$ brew install tomcat
==> Downloading https://www.apache.org/dyn/closer.cgi?path=/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz
==> Downloading from http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz
######################################################################## 100.0%
==> Caveats
To have launchd start tomcat now and restart at login:
brew services start tomcat
Or, if you don't want/need a background service you can just run:
catalina run
==> Summary
🍺 /usr/local/Cellar/tomcat/9.0.27: 640 files, 14.8MB, built in 9 seconds
希望能帮助遇到同样问题的小伙伴们.