读者建议:如果使用国外vps建议会快速很多。国内vps建议本方法。

lnmp环境配置

这里使用最新的lnmp1.4

1
wget -c http://soft.vpser.net/lnmp/lnmp1.4beta.tar.gz && tar zxf lnmp1.4beta.tar.gz && cd lnmp1.4 && ./install.sh lnmp

安装ss-panel前端

下载 ss-panel 源码

1
2
cd /home/wwwroot/
git clone https://github.com/orvice/ss-panel.git

安装好之后,是这个样子的。

mark

mark

配置 ss-panel

.env文件配置

安装依赖文件,并配置.env

1
2
3
4
cd /home/wwwroot/ss-panel/
curl -sS https://install.phpcomposer.com/installer | php
chmod +x composer.phar
php composer.phar install
  • 安装依赖那一步时间会久一些,因为一共有75个依赖,而且很多被墙了(因此如果直接用国外vps,真的会好很多),换了国内源会稍微好一些。

    漫长的等待

    漫长的等待
1
2
3
chmod -R 777 storage
cp .env.example .env
vi .env
  • 这里主要是修改数据库的内容,还有muKey

nginx配置

1
2
3
4
lnmp vhost add
# 写入站点网址
/home/wwwroot/ss-panel/public
# 允许重写规则,其余一律是n

进入nginx配置文件再修改一下:

1
cd /usr/local/nginx/conf/vhost/

完整配置文件应该是这个样子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
server {
listen 80;
#listen [::]:80;
server_name ss.feiyang.li n;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/ss.feiyang.li/public;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ [^/]\.php(/|$) {
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
fastcgi_param PHP_ADMIN_VALUE “open_basedir = /home/wwwroot/:/temp/:/proc”;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
}

新建ss数据库

1
2
3
4
5
mysql -uroot -p
# 输入自己的密码
create database ss;
use ss;
source /home/wwwroot/ss-panel/db.sql;

现在访问你的站点,就可以看到 ss-panel 啦:

添加管理员账户

文字排序会让强迫症奔溃。。。。。
php xcat createAdmin

邮箱设置

1
2
3
4
vi .env
mailgun_key = ‘key-0****c09’ //上面的KEY
mailgun_domain = ‘https://api.mailgun.net/v3/feiyang.li’ //你经过验证过的域名
mailgun_sender = ‘postmaster@****.net’ //postmaster@你经过验证过的域名

https证书

lnmp ssl add
/home/wwwroot/ss-panel/1_ss.feiyang.li_bundle.crt
/home/wwwroot/ss-panel/2_ss.feiyang.li.key
获得绿色小锁~

安装 SS PY MU 服务端

安装libsodium支持chacha20

centos:

1
2
3
4
5
6
yum -y groupinstall “Development Tools”
wget https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz
tar xf libsodium-1.0.11.tar.gz && cd libsodium-1.0.11
./configure && make -j2 && make install
echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig

ubuntu/debian:

1
2
3
4
5
apt-get install build-essential
wget https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz
tar xf libsodium-1.0.11.tar.gz && cd libsodium-1.0.11
./configure && make -j2 && make install
ldconfig

将代码 clone 到本地:

1
2
3
cd ~
git clone https://github.com/fsgmhoward/shadowsocks-py-mu.git
cd ~/shadowsocks-py-mu/shadowsocks/

其中的 shadowsocks 子目录才是我们需要的,外面的是 setup.py 的相关文件。

配置 shadowsocks-manyuser

1
2
cp config_example.py config.py
vi config.py

修改其中第 15 行和第 29~31 行的内容:

1
2
3
4
5
6
7
# 启用 MultiUser API
API_ENABLED = True
# 就是在你的站点地址后面加个 /mu
API_URL = ‘http://ss.feiyang.li/mu’
# 还记得上面在 .env 中填写的 muKey 吗?把它填在这里
API_PASS = ‘api_key_just_for_test’

由于我们选择使用 Mu API 来与前端通信,所以我们不需要修改 config.py 中任何关于数据库的配置。

好了,现在可以试着运行一下

1
python servers.py

(注意,是 servers.py 而不是 server.py)。如果没错的话,应该可以看到这样的输出:

配置 ss-manyuser 守护进程

  • 安装 supervisor (用的是上面安装过的 pip):
    1
    2
    yum install python-setuptools
    easy_install supervisor
  • 创建 supervisor 配置文件
    1
    echo_supervisord_conf > /etc/supervisord.conf
  • 运行 supervisor 服务
    1
    supervisord
  • 配置 supervisor 以监控 ss-manyuser 运行
    1
    vim /etc/supervisord.conf
  • 在文件尾部添加如下内容并酌情修改:
    1
    2
    3
    4
    5
    [program:ss-manyuser]
    command = python /root/shadowsocks-py-mu/shadowsocks/servers.py
    user = root
    autostart = true
    autorestart = true

其中 command 里的目录请自行修改为你的 servers.py所在的绝对路径。

  • 重启 supervisor 服务以加载配置
    1
    killall -HUP supervisord
  • 查看 shadowsocks-manyuser 是否已经运行:
    1
    2
    ps -ef | grep servers.py
    root 952 739 0 15:40 ? 00:00:00 python /root/shadowsocks-rm/shadowsocks/servers.py
  • 可以通过以下命令管理 shadowsock-manyuser 的状态
1
supervisorctl {start|stop|restart} ss-manyuser

谷歌BBR加速

OpenVZ 以外的( KVM 、 Xen 、 VMware 等)

1
2
3
wget –no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh
chmod +x bbr.sh
./bbr.sh

详细信息见: https://www.91yun.org/archives/5174

OpenVZ 小鸡

1
wget –no-check-certificate https://raw.githubusercontent.com/mmmwhy/LKL_BBR/master/lkl/install.sh && bash install.sh

如果运行之后,发现不能连接服务器,可能因为防火墙设置问题。可以直接关闭node节点的防火墙
对于CentOS:

1
2
service iptables stop #关闭命令:
chkconfig iptables off# 永久关闭防火墙:

详细内容见:https://www.91yun.org/archives/6281

其余常见错误:

http://feiyang.li/2017/05/03/ss-panel/index.html#常见错误

与上文一样,本文参考了如下博主文章,在此致谢:
https://blessing.studio/build-shadowsocks-sharing-site-with-ss-panel/
http://bitzhi.com/2016/03/install-ss-go-mu-and-ss-panel-v3/
https://levyhsu.com/?p=98