1. 安装 Python pip 组件
apt-get install python-pip
2. 用 pip 安装 shadowsocks
pip install shadowsocks
更新 shadowsocks 代码
pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip -U
启动代码
ssserver -p 8388 -k password-m aes-256-cfb -d start
配置文件
{
"server":"0.0.0.0",
"server_port":8388,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"pawssword",
"timeout":300,
"method":"aes-256-cfb"
}
配置文件启动方式
ssserver -c /etc/shadowsocks.json -d start
添加开机启动
vi /etc/init.d/shadowsocks
#!/bin/sh
# chkconfig: 2345 90 10
# description: Start or stop the Shadowsocks server
#
### BEGIN INIT INFO
# Provides: Shadowsocks
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start or stop the Shadowsocks server
### END INIT INFO
# Author: xju <qing0991@163.com>
name=shadowsocks
BIN=/usr/bin/ssserver
conf=/etc/shadowsocks.json
start(){
$BIN -c $conf -d start
RETVAL=$?
if ["$RETVAL" = "0"]; then
echo "$name start success"
else
echo "$name start failed"
fi
}
stop(){pid=`ps -ef | grep -v grep | grep -v ps | grep -i "${BIN}" | awk '{print $2}'`
if [! -z $pid]; then
$BIN -c $conf -d stop
RETVAL=$?
if ["$RETVAL" = "0"]; then
echo "$name stop success"
else
echo "$name stop failed"
fi
else
echo "$name is not running"
RETVAL=1
fi
}
status(){pid=`ps -ef | grep -v grep | grep -v ps | grep -i "${BIN}" | awk '{print $2}'`
if [-z $pid]; then
echo "$name is not running"
RETVAL=1
else
echo "$name is running with PID $pid"
RETVAL=0
fi
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'status')
status
;;
'restart')
stop
start
RETVAL=$?
;;
*)
echo "Usage: $0 {start | stop | restart | status}"
RETVAL=1
;;
esac
exit $RETVAL
chmod a+x /etc/init.d/shadowsocks
update-rc.d shadowsocks defaults
正文完