Debian下shadowsocks-libev一键安装脚本

技术 秋水逸冰 719887浏览 514评论

本脚本适用环境:
系统支持:Debian/Ubuntu
内存要求:≥128M
日期:2018 年 06 月 01 日

关于本脚本:
Debian 或 Ubuntu 下一键安装 libev 版的 Shadowsocks 最新版本。该版本的特点是内存占用小(600k左右),使用 libev 和 C 编写,低 CPU 消耗,甚至可以安装在基于 OpenWRT 的路由器上。
友情提示:如果你有问题,请先参考这篇《Shadowsocks Troubleshooting》后再问。

默认配置:
服务器端口:自己设定(如不设定,默认从 9000-19999 之间随机生成)
密码:自己设定(如不设定,默认为 teddysun.com)
加密方式:自己设定(如不设定,默认为 aes-256-gcm)

客户端下载:
https://github.com/shadowsocks/shadowsocks-windows/releases

使用方法:
使用root用户登录,运行以下命令:

wget --no-check-certificate -O shadowsocks-libev-debian.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-libev-debian.sh
chmod +x shadowsocks-libev-debian.sh
./shadowsocks-libev-debian.sh 2>&1 | tee shadowsocks-libev-debian.log

安装完成后,脚本提示如下:

Congratulations, Shadowsocks-libev server install completed!
Your Server IP        :your_server_ip
Your Server Port      :your_server_port
Your Password         :your_password
Your Encryption Method:your_encryption_method

Welcome to visit:https://teddysun.com/358.html
Enjoy it!

卸载方法:
使用 root 用户登录,运行以下命令:

./shadowsocks-libev-debian.sh uninstall

其他事项:
客户端配置的参考链接:https://teddysun.com/339.html
本脚本安装完成后,已将 Shadowsocks-libev 加入开机自启动。

使用命令:
启动:/etc/init.d/shadowsocks start
停止:/etc/init.d/shadowsocks stop
重启:/etc/init.d/shadowsocks restart
查看状态:/etc/init.d/shadowsocks status

更多版本 Shadowsocks 服务端一键安装脚本:
ShadowsocksR 版一键安装脚本(CentOS,Debian,Ubuntu)
Shadowsocks Python 版一键安装脚本(CentOS,Debian,Ubuntu)
CentOS 下 Shadowsocks-libev 一键安装脚本
Shadowsocks-go 一键安装脚本(CentOS,Debian,Ubuntu)
Shadowsocks 一键安装脚本(四合一)

更新日志

2018 年 06 月 01 日:
1、新增:配置文件新增 fast_open 字段,并根据系统的内核版本,判断大于 3.7.0 时启用,否则不启用;
2、修正:在使用 /etc/init.d/shadowsocks restart 命令重启服务端时,偶尔出现的 “bind: Address already in use” 问题;
3、修正:移除配置文件中的 local_address 字段;
4、修改:不再默认使用 root 用户启动,改为使用 nobody 用户启动服务端 ss-server;
5、升级:mbedtls 到版本 2.9.0;
6、修改:启动脚本中的 -u 参数(即同时启用 TCP 和 UDP 模式),改到配置文件里配置为 “mode”: “tcp_and_udp”;
7、修改:配置文件的内置 NameServers 为 8.8.8.8,默认是从 /etc/resolv.conf 中取得。

2018 年 02 月 07 日:
1、修改:将默认端口从 8989 改为从 9000-19999 之间随机生成。

2017 年 09 月 16 日:
1、修正:Shadowsocks-libev 版 v3.1.0 使用 libc-ares 替换 libudns 依赖包,解决了依赖问题;
2、升级:mbedtls 到版本 2.6.0。

2017 年 07 月 22 日:
1、修正:默认加密方式从 aes-256-cfb 改为 aes-256-gcm(官方原版客户端支持该加密方式);
2、新增:安装时可选 16 种加密方式的其中之一。如下所示:

aes-256-gcm
aes-192-gcm
aes-128-gcm
aes-256-ctr
aes-192-ctr
aes-128-ctr
aes-256-cfb
aes-192-cfb
aes-128-cfb
camellia-128-cfb
camellia-192-cfb
camellia-256-cfb
chacha20-ietf-poly1305
chacha20-ietf
chacha20
rc4-md5

2017 年 02 月 24 日:
1、恢复: 通过 Github API 自动获取 Shadowsocks-libev 的最新 release 版本的功能(v3.0.3)。

2017 年 02 月 13 日:
1、更新:升级版本到 3.0.2。
2、修复:在 Debian 7 下默认没有 libudns-dev 依赖包的问题。

2017 年 02 月 12 日:
1、更新:升级版本到 3.0.1(请下载最新的脚本来安装)。

2016 年 11 月 05 日:
1、新增:判断是否已安装,若已安装,则获取版本号与最新版比较,然后可以升级覆盖安装;
2、修正:未安装时获取最新版本号的问题。

2016 年 09 月 23 日:
1、修正:偶尔自动获取版本号失败的问题;
2、新增:自动判断如果 VPS 存在 IPv6 地址,则在配置文件里添加监听 IPv6 地址。

2016 年 09 月 17 日:
1、重构代码,自动获取 Github 上最新版来安装,不再手动修改版本号;
2、自动检测本机是否已经安装,若已安装则正常退出(若要安装新版,则需先卸载);
3、改为下载 tar.gz 包来安装,不用依赖 unzip 命令。

2016 年 09 月 12 日:
1、更新:升级版本到 2.5.2。

2016 年 09 月 11 日:
1、更新:升级版本到 2.5.1。

2016 年 08 月 29 日:
1、更新:升级版本到 2.5.0;
2、修正:由于安装时文件名的更新,卸载时文件名改为一致。

2016 年 07 月 14 日:
1、更新:升级版本到 2.4.7。

2016 年 07 月 05 日:
1、修正:新增的依赖 xmlto、asciidoc;
2、修正:由于安装时文件名的更新,卸载时文件名改为一致。

2016 年 05 月 12 日:
1、修正:Shadowsocks 服务改为强制默认开机启动。

2015 年 08 月 01 日:
1、新增:自定义服务器端口功能(如不设定,默认端口为 8989)。

2015 年 04 月 30 日:
1、修改配置文件 /etc/shadowsocks-libev/config.json 同时启用 IPv4 与 IPv6 支持:

{
    "server":["[::0]","0.0.0.0"],
    "server_port":your_server_port,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"your_password",
    "timeout":600,
    "method":"aes-256-cfb"
}

2、Shadowsocks libev 版不能通过修改配置文件来多端口(只能开启多进程),如果你需要多端口请安装 Python 或 Go 版;

2015 年 03 月 09 日:
1、新增:启动脚本/etc/init.d/shadowsocks,使用更简单。
2、修正:优化安装过程。

2014 年 10 月 31 日:
1、修正:写入自启动命令到 /etc/rc.local 中的错误。

特别说明:
已安装旧版本的 Shadowsocks 需要升级的话,需下载本脚本的最新版,直接运行即可自动升级

./shadowsocks-libev-debian.sh

参考链接:
https://github.com/shadowsocks/shadowsocks-libev

转载请注明:秋水逸冰 » Debian下shadowsocks-libev一键安装脚本

发表我的评论
取消评论

请输入正确答案后提交评论 *超出时限。 请再次填写验证码。

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (514)

  1. 厉害了我的博主!前两天还在想什么时候更新,自己按官方教程一脸懵逼。不过安装失败了。。。 Debian7 失败时提示 configure: error: in `/root/libsodium-1.0.11': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details libsodium install failed! 然后我apt-get install gcc 之后又报错 ./shadowsocks-libev-debian.sh: line 277: make: command not found 然后我又apt-get install build-essential 报错 checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking whether gcc understands -c and -o together... yes checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking for style of include used by make... GNU checking whether make supports nested variables... yes checking dependency style of gcc... gcc3 checking for ar... ar checking the archiver (ar) interface... ar checking whether make supports nested variables... (cached) yes checking whether to enable maintainer-specific portions of Makefiles... no checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking how to print strings... printf checking for a sed that does not truncate output... /bin/sed checking for fgrep... /bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 1572864 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking how to convert i686-pc-linux-gnu file names to i686-pc-linux-gnu format... func_convert_file_noop checking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for archiver @FILE support... @ checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking for sysroot... no checking for mt... mt checking if mt is a manifest tool... no checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking for shl_load... no checking for shl_load in -ldld... no checking for dlopen... no checking for dlopen in -ldl... yes checking whether a program can dlopen itself... yes checking whether a statically linked program can dlopen itself... no checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... no checking whether to build static libraries... yes checking for pcre-config... no checking for pcre location... not found configure: error: Cannot find pcre library. Configure --with-pcre=DIR make: *** No targets specified and no makefile found. Stop. Shadowsocks-libev install failed! log我放在这里了,博主您看一下https://tpedutw-my.sharepoint.com/personal/anadano_tp_edu_tw/_layouts/15/guestaccess.aspx?docid=0cfaecefea0774053a2b9ac55451addcd&authkey=AXuF5ZokIwIbBA2r06HkCRk
    anadano7年前(2017-02-13)回复
    • 这个我才解决这个问题不久,特意来回答。我也是debian 7的平台,我也遇到了“configure: error: in `/root/libsodium-1.0.11':“的情况,据我所知道的应该是debian 7的sources 里没有libsodium(不确定) 所以不能安装和编译脚本内容,要自己下载libsodium编译安装后再来运行博主的脚本。(不知道可不可以贴其它博主的内容,还是放上来吧。这是编译的libsodium过程https://www.htcp.net/2429.html,其它内容由博主补充)
      net7年前(2017-02-13)回复
    • 补充一下,好像博主的脚本里就已经提供了libsodium的编译,我是看到这个错误后按着这个修复的。终端滚得太快日志又懒得看所以直接就操作了,可能我的方法比较复杂,如果不急着搭建的话还是看看博主怎么回复吧
      net7年前(2017-02-13)回复
      • 多谢多谢,你说得没错,博主今天更新的脚本已经解决问题了
        anadano7年前(2017-02-13)回复
    • 针对 Debian 7 下默认没有 libudns-dev 依赖包的问题,已经在 2 月 13 日版的脚本里修复了。 请下载最新版脚本后重试。
      秋水逸冰7年前(2017-02-13)回复
      • 多谢博主!现在已经没问题了
        anadano7年前(2017-02-13)回复
  2. shadowsocks-libev 如何安裝3.0.1版本的?直接改脚本裏的版本好可以嗎?
    yaucy7年前(2017-02-10)回复
    • 已发布最新版脚本,安装 3.0.1,请下载最新版脚本来安装。
      秋水逸冰7年前(2017-02-12)回复
  3. 作者已经修复了吧.koolshare的固件的68u libev版本已经升级到了2.6版本以上了,是不是可以编译了.
    阿莫7年前(2017-02-03)回复
  4. ss libev已更新3.0.0版本,博主也跟进更新吧
    Aniar7年前(2017-02-01)回复
  5. ./shadowsocks-libev-debian.sh: line 159: ./configure: No such file or directory make: *** No targets specified and no makefile found. Stop. 請問這個怎麽解決呢
    XVB7年前(2017-01-27)回复
  6. 2017-01-25 02:52:51 (32.9 MB/s) - `/etc/init.d/shadowsocks' saved [2103/2103] ./shadowsocks-libev-debian.sh: line 263: ./configure: No such file or directory make: *** No targets specified and no makefile found. Stop. Shadowsocks-libev install failed! Please visit https://teddysun.com/358.html and contac
    wae7年前(2017-01-25)回复
  7. 新版2.6.3 安裝錯誤~~ ./shadowsocks-libev-debian.sh: line 265: ./configure: No such file or directory make: *** No targets specified and no makefile found. Stop.
    阿正7年前(2017-01-25)回复
  8. --2017-01-24 13:47:50-- https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-libev-debian Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.128.133, 151.101.64.133, 151.101.0.133, ... Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.128.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 2103 (2.1K) [text/plain] Saving to: ‘/etc/init.d/shadowsocks’ 0K .. 100% 8.94M=0s 2017-01-24 13:47:51 (8.94 MB/s) - ‘/etc/init.d/shadowsocks’ saved [2103/2103] ./shadowsocks-libev-debian.sh: line 265: ./configure: No such file or directory make: *** No targets specified and no makefile found. Stop. Shadowsocks-libev install failed! Please visit https://teddysun.com/358.html and contact. 请问是什么原因导致,如何解决?
    YQ Wang7年前(2017-01-24)回复
    • 作者发布的最新版 2.6.3 更改了目录结构及编译方式。 且 make rule 缺少 ss-nat,所以不管你是手动还是自动编译都肯定会失败。 目前安装脚本已经强制安装版本 2.5.6,等作者再次更新后,再跟进吧。
      秋水逸冰7年前(2017-01-27)回复
      • 秋大,之前一直用你的脚本,可一直有个问题想反馈下,就是安装完后编辑/etc/default/shadowsocks-libev是空文件,并且ss-server路径为/usr/local/bin/ss-server,并非作者的/usr/bin/ss-server,希望秋大能保持原有的基础,谢谢。
        小苹果7年前(2017-01-31)回复
        • /etc/default/shadowsocks-libev 并不是脚本里指定的配置文件,而是 /etc/shadowsocks-libev/config.json 另,至于 ss-server 的路径,默认编译的情况下,是在 /usr/local/bin/ss-server
          秋水逸冰7年前(2017-02-02)回复
  9. 你好博主,请问这个版本默认有没有开启TCP fast open呢?
    crow7年前(2017-01-22)回复
  10. checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking for shl_load... no checking for shl_load in -ldld... no checking for dlopen... no checking for dlopen in -ldl... yes checking whether a program can dlopen itself... yes checking whether a statically linked program can dlopen itself... no checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... no checking whether to build static libraries... yes checking for pcre-config... no checking for pcre location... not found configure: error: Cannot find pcre library. Configure --with-pcre=DIR make: *** No targets specified and no makefile found. Stop. 这个错误怎么解决啊
    luning7年前(2017-01-10)回复
  11. 你好 您说 2、Shadowsocks libev 版不能通过修改配置文件来多端口(只能开启多进程),如果你需要多端口请安装 Python 或 Go 版; 可是我在man里面找到配置了啊?下面是man页 有删节.
    allan7年前(2017-01-04)回复
    • 你所说的是 ss-manager 的 man 用法。 默认的启动脚本不是通过 ss-manager 来管理进程的启动与停止。 而脚本所做的功能一直就是默认一键搞定单用户配置。
      秋水逸冰7年前(2017-01-04)回复
  12. 您好 我对server端配置文件有些疑惑 1 配置文件第一个项"server":"0.0.0.0" 这里为什么填0.0.0.0?我在很多文献 包括 man 里面看到的是填写服务器的地址, 2 而且往下的"local_address":"127.0.0.1"很多文献也没有提到 这个字段就被省略了.3 您脚本里通过访问网址获得nat后的地址,这除了最后显示用还有其他用途吗? 谢谢
    allan7年前(2017-01-04)回复
  13. 版主您好,抱歉打扰了,真心求教libev如何开启多进程,因为需要udp转发还想和几个朋友合用,本人小白,又找不到一个相应的教程,希望能够帮帮忙
    一朵菊花7年前(2016-12-30)回复
    • 这个倒是可以参考我写的一篇教程
      秋水逸冰7年前(2016-12-30)回复
      • 您好,根据您写的这个教程,我执行到第五步时 root@vultr:~# su - user1 -c '/usr/local/bin/ss-server -u -c /etc/shadowsocks-libev/config.json -f /var/run/shadowsocks-server/pid1 &' No directory, logging in with HOME=/ 实在是不太明白,还希望您能解答一下
        一朵菊花7年前(2016-12-30)回复
    • 多用户我还是建议你用go或者py版
      anadano7年前(2017-01-02)回复
  14. 怎么不能更新到2.6.0?
    linus7年前(2016-12-29)回复
    • 因为 2.6.0 不是真正的 release,只是 pre-release。Github 的 API 返回值只会返回最新的 release 版本号。
      秋水逸冰7年前(2016-12-30)回复
  15. hecking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/root/shadowsocks-libev-2.5.6': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details ./shadowsocks-libev-debian.sh: line 264: make: command not found 一直说检测不到我的c编译器,但是我编译器安装了啊
    shiki7年前(2016-12-27)回复
    • 那也许就是系统 PATH 的问题了。 echo $PATH 看看是否正确配置。
      秋水逸冰7年前(2016-12-27)回复