Setup developers Mac computer - atabegruslan/Notes GitHub Wiki

PATH

In my current Mac, I have the below in my ~/.zshrc

export MAMP_PHP=/Applications/MAMP/bin/php/php8.2.0/bin
export PATH="$MAMP_PHP:$PATH"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

Above can also be put into ~/.profile

See also Linux's: https://github.com/atabegruslan/Notes/wiki/Setup-developers-Ubuntu-computer#linuxs-env-vars

MAMP with many PHP versions

Startup

Open System Preferences.
Go to Users & Groups.
Choose your nickname on the left.
Choose Login items tab.
Check startup programs you want to remove.
Press the “–” sign below.

Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    echo >> /Users/rus/.zprofile
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/rus/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"

Git

brew update
brew install git

Github SSH

ssh-keygen -t rsa -b 4096 -C "[email protected]"
eval "$(ssh-agent -s)"
pbcopy < /Users/rus/.ssh/id_rsa.pub

Node

brew install node@20

Notes

node@20 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have node@20 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/node@20/bin:$PATH"' >> ~/.zshrc

For compilers to find node@20 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/node@20/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/node@20/include"

Then open new terminal

node -v
npm -v

Yarn

npm install --global yarn

Notes

# if yarn is installed, but not linked
brew link yarn

Java

https://stackoverflow.com/questions/69875335/macos-how-to-install-java-17

brew install openjdk@17

Notes

For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk

openjdk@17 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have openjdk@17 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zshrc

For compilers to find openjdk@17 you may need to set:
  export CPPFLAGS="-I/opt/homebrew/opt/openjdk@17/include"

Then open new terminal

java -version
openjdk version "17.0.13" 2024-10-15
OpenJDK Runtime Environment Homebrew (build 17.0.13+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.13+0, mixed mode, sharing)