Ubuntu 18.04 安装 shadowsocks-libev 服务端(支持多用户)

Posted by D on January 31, 2020

参考:Ubuntu 18.04 安装 shadowsocks-libev 服务端

1. 准备编译环境

sudo apt install --no-install-recommends build-essential autoconf libtool \
         libssl-dev gawk debhelper dh-systemd init-system-helpers pkg-config asciidoc \
         xmlto apg libpcre3-dev zlib1g-dev libev-dev libudns-dev libsodium-dev \
         libmbedtls-dev libc-ares-dev automake

2. 获取shadowsocks-libev源码, 并安装

sudo apt install git
git clone https://github.com/shadowsocks/shadowsocks-libev.git
cd shadowsocks-libev
git submodule update --init
./autogen.sh && ./configure --disable-documentation && make
sudo make install

3. 创建配置文件

sudo mkdir /etc/shadowsocks-libev

单用户

sudo vi /etc/shadowsocks-libev/config.json

请根据情况修改配置文件 /etc/shadowsocks-libev/config.json 比如:

{
     "server":"0.0.0.0",
     "server_port":8388,
     "local_port":1080,
     "password":"mypassword",
     "timeout":300,
     "method":"aes-256-gcm" ,
     "fast_open": false
 }

多用户

sudo vi /etc/shadowsocks-libev/manager_config.json

请根据情况修改配置文件 /etc/shadowsocks-libev/manager_config.json 比如:

{
     "server":"0.0.0.0",
     "local_port":1080,
     "method":"aes-256-gcm" ,
     "timeout":300,
     "fast_open": true,
     "port_password": {
        "8388": "barfoo1",
        "8389": "barfoo2"
    }
 }

4. 创建Shadowsocks-libev.service配置文件

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

/etc/systemd/system/shadowsocks-libev.service内容如下:

单用户

[Unit]
Description=Shadowsocks-libev Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/ss-server -c /etc/shadowsocks-libev/config.json -u
Restart=on-abort

[Install]
WantedBy=multi-user.target

多用户

[Unit]
Description=Shadowsocks-libev Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/ss-manager -c /etc/shadowsocks-libev/manager_config.json -u
Restart=on-abort

[Install]
WantedBy=multi-user.target

5. 启动Shadowsocks:

sudo systemctl start shadowsocks-libev

6. 设置开机启动

sudo systemctl enable shadowsocks-libev

至此, Shadowsocks-libev服务器端的基本配置已经全部完成了!

7. 优化(可选)

优化 shadowsocks-libev 网络
开启 Google BBR

: