Preparing macOS Mojave as a Server Environment

Preparing macOS Mojave as a Server Environment

Administrator 51 2025-12-19

Install oh-my-zsh and switch default shell to zsh

Requirement
Command Line Tools (CLT) must be installed first:

git

Install oh-my-zsh:

sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

Then use git to clone plugins below:

git clone https://gitee.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://gitee.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://gitee.com/duchenpaul/zsh-completions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions

To activate plugins with oh-my-zsh, edit ~/.zshrc:

vim +74 ~/.zshrc`

Replace this part:

plugins=(git)

With:

plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
  zsh-completions
)

Install and downgrade homebrew package manager

Prepare brew

Install homebrew and finish configuration first:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

Change the working directory to Homebrew's repository :

cd $(brew --repo)

Downgrade Homebrew by checking out an earlier commit and lock it:

git checkout 3.5.10
git config branch.main.update false # use branch.master.update if needed

Disable Homebrew auto-update:

echo "export HOMEBREW_NO_UPDATE=1\nexport HOMEBREW_NO_AUTO_UPDATE=1\n$(cat ~/.zshrc)" > ~/.zshrc

Tap HomeBrew/core and switch to a suitable commit for OS

The commit "f165956049c" was made on Oct 25, 2021.
You can apply the same method to other taps (cask, etc.).

brew tap homebrew/core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git checkout f165956049c
git config branch.main.update false # or branch.master.update

Rebuild images of services and run them in Docker

  1. Search for an archeved version of Docker for macOS
  2. Prepare an archeved version of MySQL
  3. If running a Java project in a container, add the following to docker-compose.yaml
    security_opt:
       - seccomp=unconfined
    

Ask plt to search availiable fonts for Chinese characters

import matplotlib.font_manager as fm

fonts = sorted(set(f.name for f in fm.fontManager.ttflist))
for f in fonts:
    if any(k in f for k in ["Ping", "Hei", "Song", "Heiti", "Hiragino", "Noto", "Unicode", "STHeiti"]):
        print(f)