今天用到 tomcat,然后发现自己的版本是 8,而最新版本已经是 9 了,想着就用最新的. 卸载了 8 然后悲剧了,一直安装不了,摸了一天鱼,终于搞定了,记录一下!
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$
于是去看下国内镜像,果然,国内镜像确实不存在
结果还是悲剧...百度之,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)
我还真不信了,一直都是通过 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
灵机一动,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.
百度之,やっぱり! 需要将 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
dashudeMacBook-Pro:homebrew-core dashu$ brew update
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
...(其他更新内容太多,就不贴了)
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
希望能帮助遇到同样问题的小伙伴们.
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.