Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Linux

ใช้ Homebrew (Linuxbrew) ติดตั้งซอฟต์แวร์บน Linux และ Windows

Homebrew เดิมเป็นของ Mac בלבד ตอนนี้ v2.0.0+ รองรับ Linux และ Windows (ผ่าน WSL) บน Linux เรียกว่า Linuxbrew

ทำไมใช้ Linuxbrew แทน Package Manager ของ Distro?

  • ไม่ต้อง sudo ติดตั้งแพ็กเกจ (ติดตั้งใน home directory หรือ Linuxbrew prefix)
  • ไม่ต้องมี root privileges
  • ใช้ package manager เดียวกันทุกระบบ (Mac, Linux, Windows) — ไม่ต้องจำคำสั่งต่างกัน

System Requirements

  • GCC 4.4+
  • Linux 2.6.32+
  • Glibc 2.12+
  • 64-bit x86_64 CPU (ไม่รองรับ 32-bit)

ติดตั้ง Dependencies

  • Ubuntu/Debian: sudo apt-get install build-essential curl file git
  • Fedora/CentOS/RHEL: sudo yum groupinstall 'Development Tools' && sudo yum install curl file git

ติดตั้ง Linuxbrew

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

เพิ่มใน shell profile (bash/zsh):

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >> ~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >> ~/.profile

หากไม่ทำงาน ใส่ใน ~/.bashrc / ~/.zshrc:

export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"

ใช้งาน Linuxbrew

  • brew install <package>: ติดตั้ง (ลอง brew install gcc)
  • brew search <name>: ค้นหา formula
  • brew info <name>: รายละเอียด formula
  • brew update: อัปเดต Linuxbrew และ formulas
  • brew doctor: ตรวจสอบปัญหา (OK = "Your system is ready to brew")

เอกสารครบ: man brew หรือเว็บ Homebrew