# Shadowsocks

[Shadowsocks](https://github.com/shadowsocks)在github上有很多项目，比如`shadowsocks`、`shadowsocks-libev`、`go-shadowsocks2`以及`go-shadowsocks2`等等。其中`shadowsocks`是最初的版本，用python编写，已经很长时间没有维护了，`go-shadowsocks2`是用go语言重写的版本，`shadowsocks-libev`是用C语言重写的版本。

本教程将介绍在CentOS7上安装Shadowsocks服务器，介绍以下几种不同的安装方式

## shadowsocks-libev

### 方法一：yum安装

参考 <https://github.com/shadowsocks/shadowsocks-libev#install-from-repository-1>

该方法亲测有效

#### 添加epel源

```
$ yum -y install epel-release
```

#### 添加shadowsocks-libev的yum源

在`/etc/yum.repos.d/`目录下创建文件`librehat-shadowsocks-epel-7.repo`，内容如下

```
[copr:copr.fedorainfracloud.org:librehat:shadowsocks]
name=Copr repo for shadowsocks owned by librehat
baseurl=https://copr-be.cloud.fedoraproject.org/results/librehat/shadowsocks/epel-7-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/librehat/shadowsocks/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1
```

#### 安装

```
$ yum -y install shadowsocks-libev
```

安装成功后，会在`/usr/bin/`目录下生成`ss-server`、`ss-local`等二进制文件；会生成`/usr/lib/systemd/system/shadowsocks-libev.service`文件；以及配置文件`/etc/shadowsocks-libev/config.json`等

查看安装的版本

```
$ yum list installed | grep shadowsocks
shadowsocks-libev.x86_64               3.2.0-2.el7                     @copr:copr.fedorainfracloud.org:librehat:shadowsocks
```

#### 更改配置

修改配置文件`/etc/shadowsocks-libev/config.json`，把`server`从`127.0.0.1`修改为主机实际对外的IP，比如`192.168.2.101`，这样shadowsocks客户端才能连上；其他选项根据实际需求进行修改，配置文件样例如下：

```
{
    "server":"192.168.2.101",
    "server_port":8388,
    "local_port":1080,
    "password":"foobar!",
    "timeout":60,
    "method":"chacha20-ietf-poly1305"
}
```

#### 启动shadowsock服务

```
$ systemctl start shadowsocks-libev
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pshizhsysu.gitbook.io/linux/chang-yong-ruan-jian-an-zhuang-pian/shadowsocks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
