近期为了配置Anyconnect把vps系统升级到CENTOS7,而Shadowsocks-python也不再更新,干脆一并换为Shadowsocks-libev
1. 安装shadowsocks
$ yum install -y gcc automake autoconf libtool make build-essential curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel git
$ git clone https://github.com/shadowsocks/shadowsocks-libev.git
$ cd shadowsocks-libev
$ ./configure && make
$ make install
2. 新建shadowsocks的配置文件
$ mkdir -p /etc/shadowsocks
$ vi /etc/shadowsocks/config.json
输入以下内容:
{
"server":"0.0.0.0",
"server_port":8888,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"mypassword",
"timeout":300,
"method":"aes-256-cfb",
"fast_open": false,
"workers": 1
}
说明:服务器IP,服务端口(建议自定义),本地监听IP,本地监听端口,密码(建议自定义),超时时间,加密算法,关闭fast-open,工作进程数量为1。
3. 新建shadowsocks的service单元配置文件
$ vi /etc/systemd/system/shadowsocks-server.service
输入以下内容:
[Unit]
Description=Shadowsocks service
After=network.target
[Service]
Type=simple
User=nobody
ExecStart=/usr/local/bin/ss-server -c /etc/shadowsocks/config.json
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true
KillMode=process
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
说明:如果服务端口数值小于1024,把nobody改为root。
4. 运行shadowsocks服务并设置为开机自启:
$ systemctl start shadowsocks-server.service
$ systemctl enable shadowsocks-server.service
5. 防火墙开放shadowsocks服务端口:
$ firewall-cmd --permanent --add-port=8888/tcp
$ firewall-cmd --reload
6. 常用操作
停止shadowsocks服务
$ systemctl stop shadowsocks-server.service
取消shadowsocks开机自启
$ systemctl disable shadowsocks-server.service
查看日志文件
$ less /var/log/shadowsocks.log
时过境迁,现在shadowsocks-libev包里没有直接提供configure可以按照以下方式安装。 (2017年11月09日添加)
先安装一些必备的开发工具
$ yum groupinstall "Development Tools"
$ yum install epel-release -y
yum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto udns-devel libev-devel -y
安装mbed TLS
$ wget https://tls.mbed.org/download/mbedtls-2.6.0-apache.tgz
$ tar zxvf mbedtls-2.6.0-apache.tgz
$ cd mbedtls-2.6.0
$ make
$ make check
$ make install
安装libsodium 来源:Linux下安装libsodium,启用ss的chacha20高级加密
$ wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz
$ tar zxvf LATEST.tar.gz && cd libsodium-1.0.15
$ ./configure && make -j4 && make install
$ echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
$ ldconfig
安装c-ares
$ wget https://c-ares.haxx.se/download/c-ares-1.13.0.tar.gz
$ tar zxvf c-ares-1.13.0.tar.g
$ cd c-ares-1.13.0
$ ./configure
$ make && make check
$ make install
然后获取并安装shadowsocks-libev
$ git clone https://github.com/shadowsocks/shadowsocks-libev.git
$ cd shadowsocks-libev
$ git submodule update --init --recursive
$ ./autogen.sh && ./configure && make
$ make install
添加动态链接库配置
$ echo '/usr/local/lib' >> /etc/ld.so.conf.d/local.conf
$ echo "/usr/local/lib" >> /etc/ld.so.conf
$ /sbin/ldconfig
配置和启动都没有什么变化
推荐阅读:
评论
本文评论功能已关闭。