Skip to main content

Mac Silicon M1 Update Note

Docker

  • docker 不兼容,需要单独安装docker silicon版本

WebStorm

  • webStorm 建议安装 Silicon版本

PhpStorm

  • phpStorm 建议安装 Silicon版本

HomeBrew

  • 相关命令介绍

  • 建议安装Silicon版本

  • # This script installs Homebrew to its preferred prefix (/usr/local for macOS Intel, /opt/homebrew for Apple Silicon and /home/linuxbrew/.linuxbrew for Linux) so that you don’t need sudo when you brew install. It is a careful script; it can be run even if you have stuff installed in the preferred prefix already. It tells you exactly what it will do before it does it too. You have to confirm everything it will do before it starts.

    $ brew docter
    # 1 提示命令行版本低
    # Update them from Software Update in System Preferences or run:
    softwareupdate --all --install --force
    # If that doesn't show you any updates, run:
    sudo rm -rf /Library/Developer/CommandLineTools
    sudo xcode-select --install

    # Alternatively, manually download them from:
    # https://developer.apple.com/download/all/.
    # You should download the Command Line Tools for Xcode 13.2.1.

    # 2 执行cleanup 清理无用数据
    # Warning: Broken symlinks were found. Remove them with `brew cleanup`:
    # /usr/local/bin/hyperkit
    # /usr/local/opt/httpd
    # /usr/local/opt/php
    # /usr/local/opt/php@8.0
    # /usr/local/opt/php@8.1
    # /usr/local/share/man/man5/package-locks.5
    # /usr/local/share/man/man5/shrinkwrap-json.5
    $ brew cleanup

    # 3 安装的版本不对
    # Warning: Your Homebrew's prefix is not /opt/homebrew.
    # Some of Homebrew's bottles (binary packages) can only be used with the default
    # prefix (/opt/homebrew).
    # You will encounter build failures with some formulae.
    # Please create pull requests instead of asking for help on Homebrew's GitHub,
    # Twitter or any other official channels. You are responsible for resolving
    # any issues you experience while you are running this
    # unsupported configuration.

    # 备份记录homebrew 安装过的程序清单
    $ brew list
    # aom gdk-pixbuf libavif libxcb pango
    # apr gettext libb2 libxdmcp pcre
    # apr-util gflags libde265 libxext pcre2
    # argon2 ghostscript libev libxrender php
    # aspell giflib libevent libzip php@7.4
    # assimp glib libffi little-cms2 pinentry
    # autoconf glog libgcrypt lz4 pixman
    # bdw-gc gmp libgpg-error lzo pkg-config
    # boost gnu-getopt libheif m4 python@3.10
    # brotli gnupg libidn macos-term-size python@3.8
    # c-ares gnutls libidn2 mariadb python@3.9
    # ca-certificates gobject-introspection libksba mcrypt qcachegrind
    # cairo graphite2 liblqr md4c qt
    # cmake graphviz libmemcached mecab qt@5
    # cocoapods groonga libmetalink mecab-ipadic readline
    # composer gts libmng memcached rtmpdump
    # curl guile libnghttp2 mhash shared-mime-info
    # curl-openssl harfbuzz libomp mpdecimal snappy
    # dbus hexo libpng msgpack sphinx-doc
    # docbook httpd libpq netpbm sqlite
    # docbook-xsl hugo libproxy nettle tcl-tk
    # double-conversion hunspell libpthread-stubs newman tidy-html5
    # evernote2md icu4c librsvg nghttp2 unbound
    # fb303 imagemagick libsodium nginx unixodbc
    # fbthrift imath libssh2 node wangle
    # fizz jansson libtasn1 node@10 watchman
    # fmt jasper libtiff node@16 webp
    # folly jbig2dec libtool npth x265
    # fontconfig jemalloc libunistring oniguruma xmlto
    # freetds jpeg libusb openexr xorgproto
    # freetype jpeg-xl libuv openjpeg xz
    # fribidi jq libvmaf openldap youtube-dl
    # gd krb5 libx11 openssl@1.1 zlib
    # gdbm libassuan libxau p11-kit zstd

    # 备份php nginx的配置 如果有通过homebrew 安装nginx 和php
    # 卸载homebrew (uninstall homebrew)
    $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
    # 根据提示删除删除失败的文件夹

    # 4 安装正确的版本Silicon
    $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    # 如果出现安装错误,需要切换一下翻墙方式
    # fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
    # 删除相关下载目录 重新安装:
    $ sudo rm -rf /opt/homebrew
    $ sudo rm -rf /usr/local/var/homebrew

    # 安装成功 但是出现了一个警告 提示path中没有 brew环境变量 需要执行下面两句命令 写入path
    # Warning: /opt/homebrew/bin is not in your PATH.
    # Instructions on how to configure your shell for Homebrew
    # can be found in the 'Next steps' section below.
    # ==> Installation successful!
    # ==> Next steps:
    # - Run these two commands in your terminal to add Homebrew to your PATH:
    # echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/zhoujh/.zprofile
    # eval "$(/opt/homebrew/bin/brew shellenv)"
    $ echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/zhoujh/.zprofile
    $ eval "$(/opt/homebrew/bin/brew shellenv)"


    # ==> This script will install:
    # /opt/homebrew/bin/brew
    # /opt/homebrew/share/doc/homebrew
    # /opt/homebrew/share/man/man1/brew.1
    # /opt/homebrew/share/zsh/site-functions/_brew
    # /opt/homebrew/etc/bash_completion.d/brew
    # /opt/homebrew
    # ==> The following new directories will be created:
    # /opt/homebrew/bin
    # /opt/homebrew/etc
    # /opt/homebrew/include
    # /opt/homebrew/lib
    # /opt/homebrew/sbin
    # /opt/homebrew/share
    # /opt/homebrew/var
    # /opt/homebrew/opt
    # /opt/homebrew/share/zsh
    # /opt/homebrew/share/zsh/site-functions
    # /opt/homebrew/var/homebrew
    # /opt/homebrew/var/homebrew/linked
    # /opt/homebrew/Cellar
    # /opt/homebrew/Caskroom
    # /opt/homebrew/Frameworks

    # 5 安装相关应用
    $ brew install curl
    # If you need to have curl first in your PATH, run:
    # echo 'export PATH="/opt/homebrew/opt/curl/bin:$PATH"' >> ~/.zshrc
    $ brew install node@10
    # If you need to have node@12 first in your PATH, run:
    # echo 'export PATH="/opt/homebrew/opt/node@12/bin:$PATH"' >> ~/.zshrc
    # For compilers to find node@12 you may need to set:
    # export LDFLAGS="-L/opt/homebrew/opt/node@12/lib"
    # export CPPFLAGS="-I/opt/homebrew/opt/node@12/include"
    $ brew install node@16
    # If you need to have node@16 first in your PATH, run:
    # echo 'export PATH="/opt/homebrew/opt/node@16/bin:$PATH"' >> ~/.zshrc
    # For compilers to find node@16 you may need to set:
    # export LDFLAGS="-L/opt/homebrew/opt/node@16/lib"
    # export CPPFLAGS="-I/opt/homebrew/opt/node@16/include"
    $ brew install nginx
    # /opt/homebrew/etc/nginx/nginx.conf
    # nginx will load all files in /opt/homebrew/etc/nginx/servers/.
    $ brew install php@7.4
    # The php.ini and php-fpm.ini file can be found in:
    # /opt/homebrew/etc/php/7.4/
    $ brew install mariadb
    $ brew install qcachegrind
    # $ brew install openssl?
    $ brew install mcrypt?
    $ brew install cocoapods
    # $ brew install composer?
    $ brew install memcached
    $ brew install libmemcached?
    $ brew install newman
    $ brew install watchman
    $ brew install zlib?


    # 自我升级
    $ brew update
    # 安装的程序升级
    $ brew upgrade
    # 查看缓存的目录
    $ brew --cache
    # 升级安装CommandLineTools
    $ sudo rm -rf /Library/Developer/CommandLineTools
    $ sudo xcode-select --install
    # 安装成功后检查安装的CommandLineTools 版本
    $ llvm-gcc --version

完成php@7.4的安装

redis install from home brew

# search and install redis
$ brew search redis
$ brew info redis
$ brew install redis

# start and stop redis
$ brew services start redis
$ brew services stop redis

# config redis
$ cat /opt/homebrew/etc/redis.conf

# test redis service is running
$ redis-cli ping

# uninstall redis
$ brew uninstall redis
$ rm ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

brew 常用软件安装

# mpv 播放器 https://mpv.io/installation/ https://github.com/mpv-player/mpv
brew install --cask mpv