Skip to content

v3 Guide

sssnto edited this page Feb 6, 2020 · 6 revisions

Welcome to the ss-panel wiki! 完整版中文安装说明

本文仅记录安装方式,引用 https://github.com/maxidea-com/ss-panel/wiki/v3-Guide

注意:本教程基于ss-panel v3.0 及 ubuntu linux,服务器端包含:nginx、mysql、php5-fpm、redis。 我安装的服务器版本是Ubuntu 14.04 x86_64

ss-panel控制台使用本人定制的版本:https://github.com/sssnto/ss-panel (基于https://github.com/orvice/ss-panel,https://github.com/maxidea-com/ss-panel)

感谢 orvice (ss-panel & shadowsocks-go mu)、mengskysama (shadowsocks manyuser) 对开源的贡献!

1)设置服务器基本配置

apt-get update #更新源 1.1)设置中国时区

tzselect #运行后选择“Asia->China->Beijing Time” cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime date #此时时区正确显示为CST,例如: Sat Feb 13 16:55:55 CST 2016 1.2) 设置中文支持

vi /var/lib/locales/supported.d/local 写入:

zh_CN.GBK GBK zh_CN.GB2312 GB2312 zh_CN.GB18030 GB18030

dpkg-reconfigure locales #修改完local后重设本地语言支持 设置vi的中文支持 vi /etc/vim/vimrc 添加:

set fileencodings=utf-8,gb2312,gbk,gb18030 set termencoding=utf-8 set encoding=prc 2)安装Redis\MySQL\PHP\Nginx

2.1)安装Redis

ss-panel v3支持多种存储用户认证信息的方式,推荐使用Redis存储

apt-get install redis-server #安装完成保持默认配置即可 2.2)安装和配置MySQL

apt-get install mysql-server #安装过程会提示配置root用户密码,例如: pw123456 启动mysql:

service mysql start 创建ss用的mysql用户及数据库:

mysql -u root -p #输入root用户密码pw123456,进入mysql交互命令行 创建名为sspanel的数据库:

mysql>CREATE DATABASE sspanel character SET utf8; 创建用户ssuser密码sspasswd:

mysql>CREATE user 'ssuser'@'localhost' IDENTIFIED BY 'sspasswd'; 设置ssuer对数据库sspanel的管理权:

mysql>GRANT ALL privileges ON sspanel.* TO 'ssuser'@'localhost'; mysql>FLUSH PRIVILEGES; mysql>quit 创建一个快捷命令,进入mysql数据库,下次登录生效:

vi ~/.bash_aliases 添加一行:

alias ssdb='mysql --user=ssuser --password=sspasswd --host=localhost' 2.3) 安装PHP、Nginx、Git等

apt-get install git curl php5 php-guzzle php5-mysql nginx php5-fpm 2.4)安装PIP,并通过PIP安装cymysql

apt-get install python-pip python-m2crypto pip install --upgrade pip pip install --upgrade setuptools pip install cymysql

centos yum install python-setuptools && easy_install pip yum install m2crypto git pip install cymysql

3)安装Shadowsocks多用户版本

3.1) 安装shadowsocks manyuser

系统安装到/opt下:

cd /opt git clone -b manyuser https://github.com/mengskysama/shadowsocks.git 导入初始化数据库:

cd ./shadowsocks/shadowsocks mysql -u ssuser -psspasswd sspanel < ./shadowsocks.sql 修改配置:

vi Config.py MYSQL_HOST = 'localhost' MYSQL_PORT = 3306 MYSQL_USER = 'ssuser' MYSQL_PASS = 'sspasswd' MYSQL_DB = 'sspanel' 设置默认的加密方式:

vi config.json { "server":"0.0.0.0", #除了容器以外,VPS等云主机一般需要设置为公网IP地址 "server_ipv6": "[::]", "server_port":8388, "local_address": "127.0.0.1", "local_port":1080, "password":"m", "timeout":300, "method":"aes-256-cfb" } 测试运行shadowsocks服务器端:

service mysql start python ./server.py 看到以下输出就为正常安装成功:

INFO: loading config from config.json shadowsocks 2016-02-15 16:26:01 INFO db start server at port [50000] pass [0000000] 2016-02-15 16:26:01 INFO start server at 50000 2016-02-15 16:26:01 INFO starting server at 0.0.0.0:50000 3.2) 安装进程管理工具supervisor

apt-get install supervisor 新增shadowsocks的配置文件:

vi /etc/supervisor/conf.d/shadowsocks.conf [program:shadowsocks] command=python /opt/shadowsocks/shadowsocks/server.py -c /opt/shadowsocks/shadowsocks/config.json autorestart=true user=root 启动

service supervisor start supervisorctl reload 修改以下文件

/etc/profile /etc/default/supervisor 结尾添加3行:

ulimit -n 51200 ulimit -Sn 4096 ulimit -Hn 8192 debug查看日志:

supervisorctl tail -f shadowsocks stderr 启动/重启/停止:

supervisorctl start/restart/stop shadowsocks 4)安装ss-panel

4.1)下载ss-panel

cd /opt git clone https://github.com/sssnto/orvice-ss-panel.git https://github.com/maxidea-com/ss-panel.git 用这个地址 4.2) 下载php框架

curl -sS https://getcomposer.org/installer | php -- --install-dir=/bin --filename=composer cd /opt/ss-panel/ composer install chmod -R 777 storage 4.3) 设置ss-panel

cp .env.example .env vi .env // ss-panel v3 配置 // // !!! 修改此key为随机字符串确保网站安全 !!! key = 'testsiteforsspanel' debug = 'false' // 正式环境请确保为false #如果启动站点出现“Slim Application Error”,则把debug设置为‘true’,即可在页面上查看错误日志。 appName = 'ss控制平台v3.0' //站点名称 baseUrl = 'http://sspanel.yourdomain.com' // 站点地址 timeZone = 'PRC' // RPC 中国时间 UTC 格林时间 pwdMethod = 'sha256' // 密码加密 可选 md5,sha256 salt = '' // 密码加密用,从旧版升级请留空 theme = 'default' // 主题 authDriver = 'redis' // 登录验证存储方式,推荐使用Redis 可选: cookie,redis sessionDriver = 'redis' cacheDriver = 'redis'

// 邮件 mailDriver = 'mailgun' // mailgun or smtp #如需使用邮件提醒,例如邮件找回密码,请注册mailgun账号并设置 (https://mailgun.com/)

// 用户签到设置 checkinTime = '22' // 签到间隔时间 单位小时 checkinMin = '93' // 签到最少流量 单位MB checkinMax = '97' // 签到最多流量

// defaultTraffic = '50' // 用户初始流量 单位GB

// 注册后获得的邀请码数量 #建议禁用,设置为0,以后邀请码从admin后台手工生成 inviteNum = '0'

database 数据库配置

db_driver = 'mysql' db_host = 'localhost' db_database = 'sspanel' db_username = 'ssuser' db_password = 'sspasswd' db_charset = 'utf8' db_collation = 'utf8_general_ci' db_prefix = ''

redis

redis_scheme = 'tcp' redis_host = '127.0.0.1' redis_port = '6379' redis_database = '0' 合并ss-panel的默认数据库到shadowsocks manyuser的初始化数据库上:

mysql -u ssuser -psspasswd sspanel < db-160212.sql 添加ss-panel管理员账号:

/opt/ss-panel# php xcat createAdmin add admin/ 创建管理员帐号.....Enter your email/输入管理员邮箱: [email protected] Enter password for: [email protected] / 为 [email protected] 添加密码 1234567890pw
Email: [email protected], Password: 1234567890pw! Press [Y] to create admin..... 按下[Y]确认来确认创建管理员账户..... Y 4.3) 设置nginx

vi /etc/nginx/sites-available/default {

    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /opt/ss-panel/public;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
            try_files $uri $uri/ /index.php$is_args$args;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    #
    #       # With php5-cgi alone:
    #       fastcgi_pass 127.0.0.1:9000;
    #       # With php5-fpm:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }

修改完配置后重启动服务:

service php5-fpm restart service nginx restart service redis-server restart 5) 管理方式

5.1)前台地址

http://sspanel.yourdomain.com

5.1)后台管理地址

http://sspanel.yourdomain.com/admin

5.2)流量重置

cd /opt/ss-panel/ php xcat resetTraffic

iptables -A OUTPUT -p tcp -m multiport --dport 24,25,50,57,105,106,109,110,143,158,209,218,220,465,587 -j REJECT --reject-with tcp-reset iptables -A OUTPUT -p tcp -m multiport --dport 993,995,1109,24554,60177,60179 -j REJECT --reject-with tcp-reset iptables -A OUTPUT -p tcp -m multiport --dport 24,25,50,57,105,106,109,110,143,158,209,218,220,465,587 -j DROP iptables -A OUTPUT -p tcp -m multiport --dport 993,995,1109,24554,60177,60179 -j DROP service iptables save service iptables restart

Clone this wiki locally