menu 极光萝卜
Centos7搭建Shadowsocks
folder_special 笔记    access_time 2016-2-11   remove_red_eye 5161   comment 0

经个人在云主机安装测试,可以成功科学上网!记录下备用


安装相关组件

yum install -y gcc automake autoconf libtool make
yum install -y curl-devel zlib-devel openssl-devel perl-devel expat-devel gettext-devel

通过github安装shadowsocks

git clone https://github.com/madeye/shadowsocks-libev.git
cd shadowsocks-libev
./configure && make
make install

创建开机脚本

vi /etc/init.d/shadowsocks   #填写下方脚本
#!/bin/bash
#
# Script to run Shadowsocks in daemon mode at boot time.
# ScriptAuthor: icyboy
# Revision 1.0 - 14th Sep 2013
#====================================================================
# Run level information:
# chkconfig: 2345 99 99
# Description: lightweight secured scoks5 proxy
# processname: ss-server
# Author: Max Lv <[email protected]ail.com>;
# Run "/sbin/chkconfig --add shadowsocks" to add the Run levels.
#====================================================================
 
#====================================================================
# Paths and variables and system checks.
 
# Source function library
. /etc/rc.d/init.d/functions
 
# Check that networking is up.
#
[ ${NETWORKING} ="yes" ] || exit 0
 
# Daemon
NAME=shadowsocks-server
DAEMON=/usr/local/bin/ss-server
 
# Path to the configuration file.
#
CONF=/etc/shadowsocks/config.json
 
#USER="nobody"
#GROUP="nobody"
 
# Take care of pidfile permissions
mkdir /var/run/$NAME 2>/dev/null || true
#chown "$USER:$GROUP" /var/run/$NAME
 
# Check the configuration file exists.
#
if [ ! -f $CONF ] ; then
echo "The configuration file cannot be found!"
exit 0
fi
 
# Path to the lock file.
#
LOCK_FILE=/var/lock/subsys/shadowsocks
 
# Path to the pid file.
#
PID=/var/run/$NAME/pid
 
 
#====================================================================
 
#====================================================================
# Run controls:
 
RETVAL=0
 
# Start shadowsocks as daemon.
#
start() {
if [ -f $LOCK_FILE ]; then
echo "$NAME is already running!"
exit 0
else
echo -n $"Starting ${NAME}: "
#daemon --check $DAEMON --user $USER "$DAEMON -f $PID -c $CONF > /dev/null"
daemon $DAEMON -c $CONF -f $PID
fi
 
RETVAL=$?
[ $RETVAL -eq 0 ] && success
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
return $RETVAL
}
 
 
# Stop shadowsocks.
#
stop() {
echo -n $"Shutting down ${NAME}: "
killproc -p ${PID}
RETVAL=$?
[ $RETVAL -eq 0 ]
rm -f $LOCK_FILE
rm -f ${PID}
echo
return $RETVAL
}
 
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f $LOCK_FILE ]; then
stop
start
RETVAL=$?
fi
;;
status)
status $DAEMON
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac
 
exit $RETVAL
创建config.json并填写相关账号信息
mkdir -p /etc/shadowsocks
vi /etc/shadowsocks/config.json  #填写下方参数
{
    "server":"服务器 IP 地址",
    "server_port":8388,
    "local_address": "127.0.0.1",
    "local_port":1080,
    "password":"mypassword",
    "timeout":300,
    "method":"aes-256-cfb",
    "fast_open": false,
    "workers": 1
}

备注:

server:服务端可填写 0.0.0.0

最后赋予shadowsocks执行权限并添加开机启动即可


chmod 755 /etc/init.d/shadowsocks
chkconfig --add shadowsocks
systemctl start shadowsocks


使用说明:https://github.com/clowwindy/shadowsocks/wiki

               https://github.com/madeye/shadowsocks-libev

local_offer centos

发表评论:

account_circle
昵称不能为空
email
邮箱格式错误
link
网站格式错误
textsms