首页   注册   登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
宝塔
V2EX  ›  问与答

homebrew,搞了一天终于把这个 tomcat 给装上了!

  •  1
     
  •   jyounn · 36 天前 · 727 次点击
    这是一个创建于 36 天前的主题,其中的信息可能已经有所发展或是发生改变。

    今天用到 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.看下了输出,奇怪,为什么国内镜像不行,反而转欧美镜像了(有墙下载不下来很正常啊!)

    于是去看下国内镜像,果然,国内镜像确实不存在

    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
    [email protected] 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 [email protected] first in your PATH run:
      echo 'export PATH="/usr/local/opt/tom[email protected]/bin:$PATH"' >> ~/.bash_profile
    
    
    To have launchd start [email protected] now and restart at login:
      brew services start [email protected]
    Or, if you don't want/need a background service you can just run:
      catalina run
    ==> Summary
    🍺  /usr/local/Cellar/[email protected]/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
    

    希望能帮助遇到同样问题的小伙伴们.

    12 回复  |  直到 2019-10-21 16:16:24 +08:00
        1
    jyounn   36 天前
    第一次发帖,还不是上图...大家见谅
        2
    zhoulouzi   36 天前
    Good
        3
    julyclyde   35 天前
    我提炼一下:
    tuna 已经不提供 9024 了
    你想办法更新了 brew 之后,开始下载 9027
        4
    jyounn   35 天前
    @julyclyde 大佬总结得很精屁
        5
    julyclyde   35 天前
    @jyounn 第一遍没看懂,又仔细看了一遍
    然后猜想估计别人也跟我第一遍一样,干脆总结一下
        6
    efaun   34 天前
    docker 大法好
        7
    jyounn   32 天前
    @julyclyde 😓看来以后开头应该先总结一句
        8
    jyounn   32 天前
    @efaun 这和用啥没关系吧.虽然没研究过 docker,但是原理应该一样,需要不定期更新?
        9
    efaun   32 天前
    @jyounn #8 docker 一键部署了呗,不用配置了
        10
    jyounn   32 天前
    @efaun 了解了下,docker 是应用容器管理工具.和 homebrew 这个包管理工具功能不太一样吧.
        11
    efaun   32 天前
    @jyounn #10 我的意思是,你自己安装 tomcat,相当于安装一个软件不停点下一步,用 docker,相当于绿色软件下载即用,当然这也看个人喜好,也有人就是享受自己配置的感觉
        12
    jyounn   32 天前
    @efaun 好嘞
    关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   1244 人在线   最高记录 5043   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.3 · 24ms · UTC 17:49 · PVG 01:49 · LAX 09:49 · JFK 12:49
    ♥ Do have faith in what you're doing.