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

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Help Net Security
罗磊的独立博客
博客园 - Franky
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
爱范儿
爱范儿
月光博客
月光博客
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
GbyAI
GbyAI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
T
Threat Research - Cisco Blogs
Spread Privacy
Spread Privacy
Hacker News: Ask HN
Hacker News: Ask HN
B
Blog RSS Feed
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
I
InfoQ
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
H
Hacker News: Front Page
Scott Helme
Scott Helme
Jina AI
Jina AI
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
The Register - Security
The Register - Security
C
CERT Recently Published Vulnerability Notes
MongoDB | Blog
MongoDB | Blog
Help Net Security
Help Net Security
MyScale Blog
MyScale Blog
F
Fortinet All Blogs
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
J
Java Code Geeks
AWS News Blog
AWS News Blog
阮一峰的网络日志
阮一峰的网络日志
T
Threatpost
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog
Cloudbric
Cloudbric

逸思杂陈

家用网络 vlan 单线复用 Linux 平台 intel UHD 6xx 核显 openvino 探索 UI 区域检测的 vibe coding 复盘 mitmproxy 使用 esim 使用相关 阻止 bilibili 网页自动关注 Hexo 版本更新与技术债务 配置 Linux 作为主力操作系统 在 Linux 虚拟机中使用 PyAutoGUI 做自动化 语言的力量 联想笔记本 BIOS 跳过检测强制降级 redroid “设备未获得play保护机制认证” 问题 在 iOS 上访问安卓应用 在 VSCode 中用 Rust 刷LeetCode 跨域的那些事 给 macOS 词典增加生词本功能 关闭子进程打开的文件描述符 容器内进程优雅退出 Python 循环变量泄露与延迟绑定 bash 语法备忘 MySQL 自定义数据库路径
HomeBrew 与无 root 权限 Linux 环境包管理
Jay.Run · 2023-05-29 · via 逸思杂陈

一些公用的 Linux 服务器,处于维护以及安全考虑,一般只会提供普通权限用户给使用者。
普通用户的权限满足日常使用是够了,但是难以配置自己的开发环境,安装一些自己需要的包。

如果都从源码编译安装软件,依赖的维护过于复杂,初始编译工具链的版本可能也不满足需求,如 gcc 版本过低。
如果申请 sudo 权限或者请求更新系统或安装 docker,后期责任难以界定,运维和管理员一般也不会同意。

所以,最优方案还是有需求的用户在个人目录维护自己的工具链和环境。下文方案为围绕 HomeBrew 构建。

安装 miniconda 解决前置依赖

如果你的系统比较新,可以直接尝试安装 HomeBrew

基于上面讨论的内容,公用服务器一般存在系统版本低的问题,是 centos7 或者 centos6 也毫不稀奇,而且如 glibc 等库的版本也非常低。

安装 HomeBrew 有两个强依赖,git 及 curl,而且依赖的版本都比较高,centos7 的版本也不能满足。
另外,由于 Brew 不少软件都需要从源码编译,gcc 和良好的网络环境也不可缺少。

幸好 miniconda 能够解决以上几点问题。miniconda 只是提供 HomeBrew 安装的依赖,后续可以删除。

配置 conda 源(可选): 新建 .condarc,包含以下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https:
custom_channels:
conda-forge: https:
msys2: https:
bioconda: https:
menpo: https:
pytorch: https:
pytorch-lts: https:
simpleitk: https:

下载及安装 miniconda

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 下载
# 如果服务器的内置证书已过期, 增加 --no-check-certificate 条件跳过证书验证
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && chmod +x Miniconda3-latest-Linux-x86_64.sh

# 安装
./Miniconda3-latest-Linux-x86_64.sh -b -p ~/miniconda3
source ~/miniconda3/etc/profile.d/conda.sh

# 安装所需包
conda install -y gcc_linux-64 gxx_linux-64 curl git

# 链接 gcc,等 HomeBrew 安装完成这些链接可以删掉
cd ~/miniconda3/bin/
ln -s x86_64-conda_cos6-linux-gnu-gcc gcc
ln -s x86_64-conda_cos6-linux-gnu-cpp c++
ln -s gcc cc

配置安装环境变量

这些环境变量也可以配置到 bashrc 等文件,使之永久生效

1
2
3
4
5
6
7
8
9
10
11
# 设置 curl 和 git,可选
export HOMEBREW_CURL_PATH=~/miniconda3/bin/curl
export HOMEBREW_GIT_PATH=~/miniconda3/bin/git

# 设置安装源为清华源,如果网络畅通可忽略,清华源也可能403
export HOMEBREW_INSTALL_FROM_API=1
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"

由于没有 root 权限,HomeBrew 需要手动安装。
由于是手动安装,位置与默认安装位置不同,很多预编译的包就不能用了,都得从源码编译,所以网络和机器性能以及耐心很重要。

1
2
3
4
5
6
7
8
9
10
# 下载,也可使用清华源 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git clone https://github.com/Homebrew/brew ~/.homebrew

# 安装
eval "$(~/.homebrew/bin/brew shellenv)"
brew update --force --quiet
chmod -R go-w "$(brew --prefix)/share/zsh"

# 自动加载 brew
echo 'eval "$(~/.homebrew/bin/brew shellenv)"' >> ~/.bashrc

参考