I recently needed to get brew installed on an Amazon Linux EC2 server. I tried a few articles I found online, but ended up just building from source with four simple commands.
First, clone the Homebrew “Linuxbrew” git repository to your local machine by running the following command.
git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew
Next you’ll want to create a new directory for the compiled code.
Third you’ll want to make a link between the bin/brew folder from the git repository we pulled in earlier.
ln -s ../Homebrew/bin/brew ~/.linuxbrew/bin
Then finally you’ll want to enable the “brew” command to run from your shell.
eval $(~/.linuxbrew/bin/brew shellenv)