Monthly Archives: 十月 2016

2016-10-28 dobogi latest

dobogi-1

centos7 部署shadowsocks manyuser

1.1 获取最新版shadowsocks-rm manyuser

adduser shadowsocks
cd /home
git clone https://github.com/Acris/shadowsocks-rm.git
chown shadowsocks:shadowsocks shadowsocks-rm -R
cd shadowsocks-rm/shadowsocks

CentOS:

yum install m2crypto python-setuptools
easy_install pip

安装 cymysql支持

pip install cymysql

1.3 编辑配置文件 配置文件可参考README

# 配置 数据库地址,数据库名,端口等..   
$ vim ./config.py
# 测试是否可以正常运行
$ python servers.py

 

2.1 systemd脚本 (这是什么?

提供一个 systemd 服务脚本,写进 /etc/systemd/system/shadowsocks-rm.service 即可,需要修改其中的运行用户组以及运行路径

cat >/etc/systemd/system/shadowsocks-rm.service<<-EOF

[Unit]
Description=Shadowsocks Proxy Services(shadowsocks-rm manyuser)
After=syslog.target
After=network.target

[Service]
Type=simple
User=shadowsocks
Group=shadowsocks
WorkingDirectory=/home/shadowsocks-rm/shadowsocks
ExecStart=/usr/bin/python /home/shadowsocks-rm/shadowsocks/servers.py
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=always
Environment="USER=shadowsocks","HOME=/home/shadowsocks-rm/shadowsocks"

[Install]
WantedBy=multi-user.target
EOF

需要修改的地方有: WorkingDirectory=/home/shadowsocks-rm/shadowsocks , ExecStart=后面参数 ,Environment=后面参数

2.2 supervisor进程守护

2.2.1 安装supervisor (这是什么?

yum install supervisor

2.2.2 添加配置文件

cat >/etc/supervisord.d/shadowsocks-rm.conf<<-EOF
[program:shadowsocks-rm]
command = /usr/bin/python /home/shadowsocks-rm/shadowsocks/servers.py
directory = /home/shadowsocks-rm/shadowsocks
user = shadowsocks
autostart = true
autorestart = true
EOF

注意修改command、directory和user后面的参数