CentOS 安装 shadowsocks-libev 服务端
本教程主要用在centos7或8,因为centos环境下trojan搭建相对简单,ss因为占用资源比较小。
1、准备编译环境
CentOS 7
yum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto c-ares-devel libev-devel libsodium-devel mbedtls-devel -y
CentOS 8
yum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto c-ares-devel libev-devel -y
先从最近的源码编译安装libmbedtls和libsodium
export LIBSODIUM_VER=1.0.11
export MBEDTLS_VER=2.4.0
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
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
2、获取shadowsocks-libev源码, 并安装
yum 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
复制粘贴如下内容(注意修改密码“password”):
{
"server":"0.0.0.0",
"server_port":8388,
"password":"password",
"timeout":600,
"method":"aes-256-cfb" ,
"fast_open": false
}
4、创建Shadowsocks-libev.service配置文件
sudo vi /etc/systemd/system/shadowsocks-libev.service
复制粘贴:
[Unit]
Description=Shadowsocks-libev Server
Documentation=https://shadowsocks.org/en/
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
5、启动 Shadowsocks-libev 服务
sudo systemctl start shadowsocks-libev
6、设置开机启动
sudo systemctl enable shadowsocks-libev
设置防火墙开放端口
firewall-cmd --zone=public --add-port=8388/tcp --permanent
firewall-cmd --zone=public --add-port=8388/udp --permanent
sudo systemctl restart firewalld