访问Github搜索项目ShadowsocksX-NG然后下载客户端或者访问 https://github.com/shadowsocks/ShadowsocksX-NG/releasesa 下载客户端
下载完成,找到下载的文件, 解压下载的dmg文件,将ShadowsocksX-NG文件拖入“应用程序”文件夹中

启动ShadowsocksX-NG,点击服务器设置,添加socke服务器,新建服务器后添加服务器地址然后进行保存
![]()


终端篇:
ShadowsocksX-NG可以使MAC访问外网,但是却无法使终端访问外网,在日常使用中,经常会需要在终端(Terminal)中运行一些命令,诸如homebrew、pod、git clone等,这些命令执行的下载,大多都是挂在外网,终端无法访问的话,速度简直感人。
1. 终端设置Shell为zsh
关于zsh的好用之处,这里就不赘述了。这里说一下如何设置zsh为默认shell。
# 查看系统支持的shell,看是否已经安装shell
cat /etc/shells
# 查看当前使用的shell
echo $SHELL
# 使用homebrew安装zsh
brew install zsh
# 设置zsh为默认shell
chsh -s /bin/zsh
2. 安装oh-my-zsh
oh-my-zsh是一个开源的框架,用来管理zsh配置的,基本上和zsh是标配。 oh-my-zsh in Github.com
# 下载+安装oh-my-zsh
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
curl是一个url传输的命令,可以理解成下载。
安装完之后,zsh的一些具体用法、插件、主题,都可以搜索的到,网上很多教程。
3. 打开.zshrc文件
zsh安装完成后 ,在Mac的根目录会出现一个.zshrc的文件,用sublime或者vim打开可以编辑。如果没有开启文件隐藏显示的话,在终端使用ls等命令可以找到。
# vim打开.zshrc文件
vim ./.zshrc
# 如果不会使用vim
# 将隐藏文件显示出来
defaults write com.apple.finder AppleShowAllFiles -bool true
# 在根目录下使用open命令
open .
打开.zshrc文件之后,我们会发现文件里是这样的,地址、主题之类的,都不用管,我们可能“”里的也不一样,也不用管。
# Path to your oh-my-zsh installation.
export ZSH=/Users/Soda/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
# User configuration
# export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
# export MANPATH="/usr/local/man:$MANPATH"
source $ZSH/oh-my-zsh.sh
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
eval $(thefuck --alias)
4. 配置过程
#开启控制台访问外网 执行以下命令 export http_proxy = http://127.0.0.1:1087 export https_proxy = http://127.0.0.1:1087 # 配置代理开关
- ~/.bash_profile 文件配置代理开关
在 Mac 终端用 vim 编辑器打开 ~/.bash_profile环境变量配置文件,添加如下配置代码
# ------terminal http proxy ----------
function proxy_on() {
export http_proxy = http://127.0.0.1:1087
export https_proxy = http://127.0.0.1:1087
echo - e "已开启代理"
}
function proxy_off() {
unset http_proxy
unset https_proxy
echo - e "已关闭代理"
}
- 在终端直接运行
proxy_on即可打开终端 http 代理,proxy_off关闭代理
注意:http://127.0.0.1:1087表示使用本地回环 ip 地址,端口是 Shadowsocks 开启的 HTTP 代理端口。具体可在 Shadowsocks 偏好设置里查看,如果没有开启 HTTP 代理,需要开启一下!
