Ubuntu 16.04编译shadowsocks-libev

in Shares with 0 comment

网上太多关于编译SS的文章都是千篇一律你抄我我抄你
于是打算自己写一篇可用的简易教程

依赖安装

3.0以后的版本需要mbedTLS和libsodium
这个在Github上已经有非常详细的编译步骤就不多赘述了

export LIBSODIUM_VER=1.0.11
export MBEDTLS_VER=2.4.0
wget https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-$LIBSODIUM_VER.tar.gz
tar xvf libsodium-$LIBSODIUM_VER.tar.gz
pushd libsodium-$LIBSODIUM_VER
./configure --prefix=/usr && make
sudo make install
popd
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
sudo make DESTDIR=/usr install
popd
sudo ldconfig

编译前还有一些别的依赖需要安装

apt update
apt install --no-install-recommends gettext build-essential autoconf automake libtool gawk debhelper dh-systemd init-system-helpers pkg-config asciidoc xmlto libpcre3-dev libev-dev libudns-dev dh-autoreconf libmbedtls-dev libsodium-dev apg

从源码编译

cd /usr/local/src
rm *shadowsocks-libev*.{deb,changes}
git clone https://github.com/shadowsocks/shadowsocks-libev.git --recursive
cd shadowsocks-libev
./autogen.sh
dpkg-buildpackage -b -us -uc -i -d
cd ..
dpkg -i *shadowsocks-libev*.deb

编辑配置文件

nano /etc/shadowsocks-libev/config.json

内容大致如下:

{
    "server": "0.0.0.0",
    "server_port": 1234,
    "local_address": "127.0.0.1",
    "local_port": 1080,
    "password": "xxxxx",
    "timeout": 300,
    "method":"aes-128-gcm",
    "fast_open": true
}

连接测试

ss-server -c /etc/shadowsocks-libev/config.json

测试一下是否能正常FQ
正常则将SS设置为自启动

systemctl start shadowsocks-libev
systemctl enable shadowsocks-libev

编译后的更新

cd /usr/local/src
rm *shadowsocks-libev*.{deb,changes}
cd shadowsocks-libev
git pull
git submodule update --init --recursive || (git submodule deinit -f .; git submodule init; git submodule update --recursive)
apt update
apt install --no-install-recommends gettext build-essential autoconf automake libtool gawk debhelper dh-systemd init-system-helpers pkg-config asciidoc xmlto libpcre3-dev libev-dev libudns-dev dh-autoreconf libmbedtls-dev libsodium-dev apg
./autogen.sh
dpkg-buildpackage -b -us -uc -i -d
cd ..
dpkg -i *shadowsocks-libev*.deb
systemctl restart shadowsocks-libev
Responses