shadowsocks-libev 安装方式举例

shadowsocks-libev 安装方式举例

shadowsocks-libev 信息

1
2
3
4
5
6
# 编译安装情况
$ ss-server -h
# 安装位置 /usr/local/bin
$ ss-local、ss-manager、ss-nat、ss-redir、ss-server、ss-tunnel
# 配置文件 /etc/shadowsocks-libev/config.json
# 日志位置/var/log/syslog
  • obfs-tls
1
2
3
4
5
6
cloudfront.com
cloudflare.com
itunes.apple.com
www.icloud.com
ajax.microsoft.com
apps.bdimg.com

编译安装

  • 编译依赖

libsodiummbedtls

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

# install dependencies
yum update -y
yum install -y pcre pcre-devel git gettext gcc autoconf libtool automake make asciidoc xmlto c-ares-devel libev-devel

export LIBSODIUM_VER=1.0.13
wget https://download.libsodium.org/libsodium/releases/libsodium-$LIBSODIUM_VER.tar.gz
tar xvf libsodium-$LIBSODIUM_VER.tar.gz
pushd libsodium-$LIBSODIUM_VER
./configure --prefix=/usr && make
make install
popd
ldconfig

export MBEDTLS_VER=2.6.0
wget https://tls.mbed.org/download/mbedtls-$MBEDTLS_VER-gpl.tgz
tar xvf mbedtls-$MBEDTLS_VER-gpl.tgz
pushd mbedtls-$MBEDTLS_VER
make SHARED=1 CFLAGS=-fPIC
make DESTDIR=/usr install
popd
ldconfig
  • 编译安装
1
2
3
4
5
6
7
8
9
10
11
12
13
# clean directory
rm -rf /tmp/shadowsocks-libev
# compile and install
cd /tmp
git clone https://github.com/shadowsocks/shadowsocks-libev.git
cd shadowsocks-libev
git submodule update --init --recursive
./autogen.sh
./configure
make
make install
cd ..
rm -rf /tmp/shadowsocks-libev
  • 配置文件
1
2
3
$ mkdir -p /etc/shadowsocks-libev
$ vi /etc/shadowsocks-libev/config.json
$ vi /var/lib/snapd/snap/shadowsocks-libev/
1
2
3
4
5
6
7
8
9
{
"server":"ip",
"server_port":9999,
"password":"xxx",
"local_port":1080,
"timeout":60,
"method":"rc4-md5",
“fast_open”:false
}
  • 环境变量

vi /etc/default/shadowsocks-libev

1
2
3
4
5
6
7
8
9
10
11
# Enable during startup?
START=yes
# Configuration file
CONFFILE="/etc/shadowsocks-libev/config.json"
# Extra command line arguments
DAEMON_ARGS="-u"
# User and group to run the server as
USER=nobody
GROUP=nobody
# Number of maximum file descriptors
MAXFD=32768
  • 设置开机自动启动

vi /etc/systemd/system/shadowsocks-libev.service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Unit]
Description=Shadowsocks-libev Default Server Service
Documentation=man:shadowsocks-libev(8)
After=network.target

[Service]
Type=simple
EnvironmentFile=/etc/default/shadowsocks-libev
User=nobody
Group=nobody
LimitNOFILE=32768
ExecStart=/usr/local/bin/ss-server -c $CONFFILE $DAEMON_ARGS

[Install]
WantedBy=multi-user.target
1
2
3
4
$ systemctl daemon-reload
$ systemctl enable shadowsocks-libev.service
$ systemctl start shadowsocks-libev.service
$ systemctl status shadowsocks-libev.service
  • 编译更新
1
$ systemctl stop shadowsocks-libev.service

shadowsocks-libev 目录下:

1
2
3
4
5
6
7
8
9
10
删除文件夹直接重新编译就好了
$ make uninstall //卸载
$ git pull
$ git submodule update –init –recursive
$ make clean //读取 Makefile 中关于 clean 的工作,清除编译过的目标文件 (*.o)
$ ./autogen.sh
$ ./configure
$ make
$ make install
$ ss-server -h //查看版本信息

yum 安装

Repository https://copr.fedorainfracloud.org/coprs/librehat/shadowsocks/

https://copr.fedorainfracloud.org/coprs/librehat/shadowsocks/repo/epel-7/librehat-shadowsocks-epel-7.repo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 版本不是最新
$ wget https://copr.fedorainfracloud.org/coprs/librehat/shadowsocks/repo/epel-7/librehat-shadowsocks-epel-7.repo
$ cp librehat-shadowsocks-epel-7.repo /etc/yum.repos.d/
$ yum update
$ yum install -y shadowsocks-libev
# 殊途同归
$ cd /etc/yum.repos.d/
$ curl -O https://copr.fedorainfracloud.org/coprs/librehat/shadowsocks/repo/epel-7/librehat-shadowsocks-epel-7.repo
$ yum update
$ yum install -y shadowsocks-libev
# 默认配置文件位置 /etc/shadowsocks-libev/config.json
$ systemctl start shadowsocks-libev.service
$ systemctl enable shadowsocks-libev.service
$ systemctl status shadowsocks-libev

snap 安装

1
2
3
4
$ sudo yum install epel-release
$ sudo yum install snapd
$ sudo systemctl enable --now snapd.socket
$ sudo ln -s /var/lib/snapd/snap /snap
1
2
$ sudo snap install core
$ sudo snap install shadowsocks-libev --edge
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# snap 安装情况
$ shadowsocks-libev.ss-server -h
# 安装位置 /var/lib/snapd/snap/shadowsocks-libev/bin
# 配置文件 /var/lib/snapd/snap/shadowsocks-libev/
配置文件放在此目录下,否则出错

$ vi /etc/systemd/system/shadowsocks-libev.service

[Unit]
Description=Shadowsocks
[Service]
TimeoutStartSec=0
ExecStart=/var/lib/snapd/snap/bin/shadowsocks-libev.ss-server -c /var/lib/snapd/snap/shadowsocks-libev/config.json -u
[Install]
WantedBy=multi-user.target

$ systemctl daemon-reload
$ systemctl enable shadowsocks-libev.service
$ systemctl start shadowsocks-libev.service
$ systemctl status shadowsocks-libev.service

docker 运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
mkdir -p /etc/shadowsocks-libev
nano /etc/shadowsocks-libev/config.json

{
"server":"0.0.0.0",
"server_port":13663,
"password":"FXvZ8vjGNB",
"timeout":300,
"method":"aes-256-gcm",
"fast_open":false,
"nameserver":"8.8.8.8",
"mode":"tcp_and_udp",
"plugin":"obfs-server",
"plugin_opts":"obfs=tls"
}

$ docker run -d -p 13663:13663 -p 13663:13663/udp --name ss-libev --restart=always -v /etc/shadowsocks-libev:/etc/shadowsocks-libev teddysun/shadowsocks-libev