惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
U
Unit 42
D
Docker
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
Recent Announcements
Recent Announcements
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
V
Visual Studio Blog
I
InfoQ
Google DeepMind News
Google DeepMind News
小众软件
小众软件
L
LangChain Blog
C
Check Point Blog
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
J
Java Code Geeks
罗磊的独立博客

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19)
CentOS 7 下安装并配置 Homebrew
微信公众号 · 2021-03-28 · via 陈少文的网站

Please enable Javascript to view the contents

在 CentOS 下安装包时,通常需要寻找各种源,使用 Homebrew 就没这样的烦恼。本文使用的是 CentOS 7.6,不同的系统版本可能会有差异。

1. 创建非 root 用户

Homebrew 不允许以 root 身份运行,因此需要创建一个新的用户。

  1. 新建用户
  1. 设置密码
  1. 给新用户添加 sudo 权限

编辑权限配置文件:

1
2
chmod +w /etc/sudoers
vi /etc/sudoers

添加如下内容

1
shaowenchen    ALL=(ALL:ALL)   ALL

恢复文件权限

2. 安装并配置 Homebrew

2.1 安装必要的基础软件

本文安装的是 Homebrew 3.0.9 , 官方文档中描述存在如下依赖:

* GCC 4.7.0 or newer
* Linux 2.6.32 or newer
* Glibc 2.13 or newer
* 64-bit x86_64 CPU

可以跳过 GCC 的检查,之后使用 Homebrew 进行安装。

  • 检查内核版本
1
2
3
uname -a

Linux myhost 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • 检查 Glibc 版本
1
2
3
4
5
6
7
ldd --version

ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
  • 安装基础软件
1
2
yum groupinstall -y ‘Development Tools’
yum install -y curl file git

2.2 升级 git 和 curl

  • 升级 git 版本,不低于 2.7.0
1
yum install -y https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm

升级版本

查看版本

1
2
3
git --version

git version 2.30.1
  • 升级 curl 版本,不低于 7.41.0
1
yum install -y http://www.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-2-1.rhel7.noarch.rpm

编辑源文件,开启 [city-fan.org],将 enabled 置为 1。

1
2
3
4
5
vi /etc/yum.repos.d/city-fan.org.repo

[city-fan.org]
...
enabled=1

安装依赖

1
yum install -y https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/l/libnghttp2-1.33.0-1.1.el7.x86_64.rpm

升级版本

查看版本

1
2
3
curl --version

curl 7.75.0

3. 安装 Homebrew

  • 切换到非 root 用户
  • 安装 Homebrew
1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • 添加 brew 命令到 PATH
1
2
3
4
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

直接将 .linuxbrew/bin 添加到 PATH 会导致安装新工具时,make 报错。

  • 查看版本
1
2
3
4
brew  --version

Homebrew 3.0.9
Homebrew/homebrew-core (git revision 1ce004f2f0b; last commit 2021-03-28)
  • [可选]添加 brew 到 Zsh
test -r ~/.zshrc && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.zshrc

4. 使用

之前写过一篇 《Homebrew 使用》 ,介绍了一些常用的命令,这里不再重复。仅安装几个常用的软件,用于测试。

  • 安装 GCC
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
brew install gcc

==> Downloading https://linuxbrew.bintray.com/bottles/isl-0.23.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/46/46537a01a0cc82ea18528293b6bac03be7ab14b2fc3a7a28051f1b26e24f6c57?__gda__=exp=1616978202~hmac=b7727c9ae79b54bebc199a095c01e70251446ed4012bfb5900dd877e06229fd1&response-content-disposition=attachment%3Bfilename%3D%22isl-0
######################################################################## 100.0%
==> Downloading https://linuxbrew.bintray.com/bottles/gcc-10.2.0_4.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/e6/e62efea399fd03d854ff871210b941e5c3277d821e9148badceeda883f53f016?__gda__=exp=1616978204~hmac=a7e19e02629bc1c462635349fe3c01039f581e2014153c704f72e54bc2d93c35&response-content-disposition=attachment%3Bfilename%3D%22gcc-1
#################                                                         24.9%
######################################################################## 100.0%
==> Installing dependencies for gcc: isl
==> Installing gcc dependency: isl
==> Pouring isl-0.23.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/isl/0.23: 73 files, 6.6MB
==> Installing gcc
==> Pouring gcc-10.2.0_4.x86_64_linux.bottle.tar.gz
Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall gcc
==> Summary
🍺  /home/linuxbrew/.linuxbrew/Cellar/gcc/10.2.0_4: 1,481 files, 264.3MB
==> No outdated dependents to upgrade!
==> Checking for dependents of upgraded formulae...
==> Reinstalling 1 broken dependent from source:
gcc
  • 安装 Kubectl
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
brew install kubectl

==> Downloading https://linuxbrew.bintray.com/bottles/kubernetes-cli-1.20.4_1.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/c5/c5dd394d0bd150aff18ded31f29e52ece6dcbd064ebe46e7f746891822a12eff?__gda__=exp=1616978407~hmac=13c24ddb7a7e90118b1aa8184d2c4688f719a945c4f0d033352a7cae9c845887&response-content-disposition=attachment%3Bfilename%3D%22kuber
######################################################################## 100.0%
==> Pouring kubernetes-cli-1.20.4_1.x86_64_linux.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /home/linuxbrew/.linuxbrew/etc/bash_completion.d
==> Summary
🍺  /home/linuxbrew/.linuxbrew/Cellar/kubernetes-cli/1.20.4_1: 246 files, 40.9MB
  • 安装 Kind
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
brew install kind

==> Downloading https://linuxbrew.bintray.com/bottles/kind-0.10.0.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/7a/7a5595da7f271219a53cbd95a5b729c581fb3e4f8ece6d449074cbe33f10d627?__gda__=exp=1616978455~hmac=754a3789f01e3c27ebdfa1b65e51392eaeacf61f878a9d607b78d342f52c5dfa&response-content-disposition=attachment%3Bfilename%3D%22kind-
######################################################################## 100.0%
==> Pouring kind-0.10.0.x86_64_linux.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /home/linuxbrew/.linuxbrew/etc/bash_completion.d
==> Summary
🍺  /home/linuxbrew/.linuxbrew/Cellar/kind/0.10.0: 8 files, 9.4MB

5. 参考


微信公众号