编译安装shadowsocksr-libev

Mac编译安装

mac编译前可能遇到错误openssl not found, 可以通过如下配置再编译:

1
2
3
export LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/local/opt/expat/lib"
export CFLAGS="-I/usr/local/opt/openssl/include/ -I/usr/local/include -I/usr/local/opt/expat/include"
export CPPFLAGS="-I/usr/local/opt/openssl/include/ -I/usr/local/include -I/usr/local/opt/expat/include"

or

1
export LIBRARY_PATH="/usr/local/opt/openssl/lib"

开始安装:

PS: 如果代码同步过慢可以先上github下载!

1
2
3
4
5
6
7
git clone https://github.com/shadowsocksr-backup/shadowsocksr-libev.git
cd shadowsocksr-libev
sudo ./configure --prefix=/usr/local/shadowsocksR --disable-documentation
sudo make -j4
sudo make install
sudo mkdir /usr/local/shadowsocksR/conf
sudo vi /usr/local/shadowsocksR/conf/config.json

加入以下内容,并根据自己的服务器进行正确修改

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"server":"your server address here",
"server_port":1234,
"local_port":1080,
"password":"your password here",
"timeout":600,
"method":"加密方式,none",
"protocol":"协议:auth_aes128_md5|auth_chain_a",
"obfs":"混淆:tls1.2_ticket_auth|http_simple",
"obfs_param":"混淆参数" ,
"group":"any you like",
"local_address":"0.0.0.0",
}

启动服务:

1
/usr/local/shadowsocksR/bin/ss-local -c /usr/local/shadowsocksR/conf/config.json

mac自启动配置:

1
vim ~/Library/LaunchAgents/com.ssr.launcher.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ssr.launcher.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/shadowsocksR/bin/ss-local</string>
<string>-c</string>
<string>/usr/local/shadowsocksR/conf/config.json</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

如果有多个,可以这样配置:

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
cat > ~/Library/LaunchAgents/com.ssr_hk.launcher.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ssr_hk.launcher.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/shadowsocksR/bin/ss-local</string>
<string>-c</string>
<string>/usr/local/shadowsocksR/conf/ssg_hk.json</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOF
cat > ~/Library/LaunchAgents/com.ssr_tw.launcher.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ssr_tw.launcher.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/shadowsocksR/bin/ss-local</string>
<string>-c</string>
<string>/usr/local/shadowsocksR/conf/ssg_tw.json</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOF

启动服务:

1
2
3
4
5
6
launchctl unload ~/Library/LaunchAgents/com.ssr.launcher.plist
launchctl load ~/Library/LaunchAgents/com.ssr.launcher.plist
launchctl unload ~/Library/LaunchAgents/com.ssr_hk.launcher.plist
launchctl load ~/Library/LaunchAgents/com.ssr_hk.launcher.plist
launchctl unload ~/Library/LaunchAgents/com.ssr_tw.launcher.plist
launchctl load ~/Library/LaunchAgents/com.ssr_tw.launcher.plist