Mac搭配homebrew简直舒爽啊,然而homebrew托管在github,对国内用户来说不仅频频被墙,而且速度也不理想。今天笔者就告诉大家国内用户顺畅访问homebrew的方法。
中科大的镜像
中科大镜像比较稳定,而且速度不错。官方网站:http://mirrors.ustc.edu.cn
搜索brew,然后点击Help即可查看用法:
替换Homebrew默认源
# 替换brew.git: cd "$(brew --repo)" git remote set-url origin https://mirrors.ustc.edu.cn/brew.git # 替换homebrew-core.git: cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git brew update 替换<span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/homebrew" title="View all posts in Homebrew" target="_blank">Homebrew</a></span> Bottles源 对于bash用户: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile 对于zsh用户: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc 清华大学镜像 也是比较靠谱的开源镜像。官方网站:https://mirror.tuna.tsinghua.edu.cn/help/homebrew/。 替换<span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/homebrew" title="View all posts in Homebrew" target="_blank">Homebrew</a></span>默认源 # 替换brew.git: cd "$(brew --repo)" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git # 替换homebrew-core.git: cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git brew update 使用homebrew-science或者homebrew-<span class="wp_keywordlink"><a href="http://www.168seo.cn/python" title="python">python</a></span> cd "$(brew --repo)/Library/Taps/homebrew/homebrew-science" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-science.git cd "$(brew --repo)/Library/Taps/homebrew/homebrew-<span class="wp_keywordlink"><a href="http://www.168seo.cn/python" title="python">python</a></span>" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-<span class="wp_keywordlink"><a href="http://www.168seo.cn/python" title="python">python</a></span>.git brew update 替换<span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/homebrew" title="View all posts in Homebrew" target="_blank">Homebrew</a></span> Bottles源 对于bash用户: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile 对于zsh用户: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc 其它镜像 搬http://ban.ninja/ 此为Homebrew Bottles源,及下载二进制文件地址: bash用户: echo 'export HOMEBREW_BOTTLE_DOMAIN=http://7xkcej.dl1.z0.glb.clouddn.com' >> ~/.bash_profile source ~/.bash_profile 对于zsh用户: echo 'export HOMEBREW_BOTTLE_DOMAIN=http://7xkcej.dl1.z0.glb.clouddn.com' >> ~/.zshrc source ~/.zshrc coding homebrew 只有Homebrew源,没有二进制文件源。 cd "$(brew --repo)" git remote set-url origin https://git.coding.net/homebrew/homebrew.git brew update 重置Homebrew默认源 # 重置brew.git: cd "$(brew --repo)" git remote set-url origin https://github.com/Homebrew/brew.git # 重置homebrew-core.git: cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://github.com/Homebrew/homebrew-core.git brew update 其它加速方法 除了通过替换源加速之外,如果你有自己的代理,也可以通过代理加速。 如socks代理配置: vi ~/.curlrc # 改成自己的代理端口 <span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/socks5" title="View all posts in socks5" target="_blank">socks5</a></span>=127.0.0.1:1080 或者通过proxychains: brew install <span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/proxychains-ng" title="View all posts in proxychains-ng" target="_blank">proxychains-ng</a></span> 然后在/usr/local/etc/proxychains.conf配置代理信息,即在 [ProxyList] 下面(也就是末尾)加入代理类型,代理地址和端口,如: <span class="wp_keywordlink_affiliate"><a href="https://www.168seo.cn/tag/socks5" title="View all posts in socks5" target="_blank">socks5</a></span> 127.0.0.1 1080 配置好之后就可以在需要使用代理的命令前加proxychians来加速: proxychians brew update proxychians brew install ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# 替换brew.git:
cd
"$(brew --repo)"
git
remote
set
-
url
origin
https
:
/
/
mirrors
.
ustc
.
edu
.
cn
/
brew
.
git
# 替换homebrew-core.git:
cd
"$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git
remote
set
-
url
origin
https
:
/
/
mirrors
.
ustc
.
edu
.
cn
/
homebrew
-
core
.
git
brew
update
替换
Homebrew
Bottles源
对于
bash用户:
echo
'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles'
&
gt
;
&
gt
;
~
/
.
bash_profile
source
~
/
.
bash
_profile
对于
zsh用户:
echo
'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles'
&
gt
;
&
gt
;
~
/
.
zshrc
source
~
/
.
zshrc
清华大学镜像
也是比较靠谱的开源镜像。官方网站:
https
:
/
/
mirror
.
tuna
.
tsinghua
.
edu
.
cn
/
help
/
homebrew
/。
替换
Homebrew默认源
# 替换brew.git:
cd
"$(brew --repo)"
git
remote
set
-
url
origin
https
:
/
/
mirrors
.
tuna
.
tsinghua
.
edu
.
cn
/
git
/
homebrew
/
brew
.
git
# 替换homebrew-core.git:
cd
"$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git
remote
set
-
url
origin
https
:
/
/
mirrors
.
tuna
.
tsinghua
.
edu
.
cn
/
git
/
homebrew
/
homebrew
-
core
.
git
brew
update
使用
homebrew
-
science或者
homebrew
-
python
cd
"$(brew --repo)/Library/Taps/homebrew/homebrew-science"
git
remote
set
-
url
origin
https
:
/
/
mirrors
.
tuna
.
tsinghua
.
edu
.
cn
/
git
/
homebrew
/
homebrew
-
science
.
git
cd
"$(brew --repo)/Library/Taps/homebrew/homebrew-python"
git
remote
set
-
url
origin
https
:
/
/
mirrors
.
tuna
.
tsinghua
.
edu
.
cn
/
git
/
homebrew
/
homebrew
-
python
.
git
brew
update
替换
Homebrew
Bottles源
对于
bash用户:
echo
'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles'
&
gt
;
&
gt
;
~
/
.
bash_profile
source
~
/
.
bash
_profile
对于
zsh用户:
echo
'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles'
&
gt
;
&
gt
;
~
/
.
zshrc
source
~
/
.
zshrc
其它镜像
搬
http
:
/
/
ban
.
ninja
/
此为
Homebrew
Bottles源,及下载二进制文件地址:
bash用户:
echo
'export HOMEBREW_BOTTLE_DOMAIN=http://7xkcej.dl1.z0.glb.clouddn.com'
&
gt
;
&
gt
;
~
/
.
bash_profile
source
~
/
.
bash
_profile
对于
zsh用户:
echo
'export HOMEBREW_BOTTLE_DOMAIN=http://7xkcej.dl1.z0.glb.clouddn.com'
&
gt
;
&
gt
;
~
/
.
zshrc
source
~
/
.
zshrc
coding
homebrew
只有
Homebrew源,没有二进制文件源。
cd
"$(brew --repo)"
git
remote
set
-
url
origin
https
:
/
/
git
.
coding
.
net
/
homebrew
/
homebrew
.
git
brew
update
重置
Homebrew默认源
# 重置brew.git:
cd
"$(brew --repo)"
git
remote
set
-
url
origin
https
:
/
/
github
.
com
/
Homebrew
/
brew
.
git
# 重置homebrew-core.git:
cd
"$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git
remote
set
-
url
origin
https
:
/
/
github
.
com
/
Homebrew
/
homebrew
-
core
.
git
brew
update
其它加速方法
除了通过替换源加速之外,如果你有自己的代理,也可以通过代理加速。
如
socks代理配置:
vi
~
/
.
curlrc
# 改成自己的代理端口
socks5
=
127.0.0.1
:
1080
或者通过
proxychains:
brew
install
proxychains
-
ng
然后在
/
usr
/
local
/
etc
/
proxychains
.
conf配置代理信息,即在
[
ProxyList
]
下面(也就是末尾)加入代理类型,代理地址和端口,如:
socks5
127.0.0.1
1080
配置好之后就可以在需要使用代理的命令前加
proxychians来加速:
proxychians
brew
update
proxychians
brew
install
.
.
.
|