此文档非来自原作者的 wiki
前端使用赵大的魔改版(new_master分支) https://github.com/esdeathlove/ss-panel-v3-mod
后端也使用赵大的魔改版 https://github.com/esdeathlove/shadowsocks
安装前端
安装LNMP
screen -S lnmp wget http://soft.vpser.net/lnmp/lnmp1.4-full.tar.gz && tar xvzf lnmp1.4-full.tar.gz cd lnmp1.4-full && ./install.sh
安装过程要求输入MySQL密码, 选择MySQL版本>=5.5, PHP版本>7.0.
安装大概需要半小时, 如果中途 ssh 断线, 输入 screen -r lnmp
设置虚拟主机
lnmp vhost add
要求输入你的域名, 然后其余项默认即可, SSL 开启
接着修改下 nginx
编辑 /usr/local/nginx/conf/vhost/你的域名.conf
然后添加下面内容到 server
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; }
修改 root 那一行为
root /home/wwwroot/你的域名/public;
下载 sspanel 代码
cd /home/wwwroot/你的域名 apt-get install git -y git clone -b new_master https://github.com/glzjin/ss-panel-v3-mod.git tmp && mv tmp/.git . && rm -rf tmp && git reset --hard chown -R root:root * chmod -R 755 * chown -R www:www storage chattr -i .user.ini mv .user.ini public cd public chattr +i .user.ini service nginx restart
LNMP1.4需要修改防跨目录的设置, 否则肯定报错
cd ~/lnmp1.4/tools/ ./remove_open_basedir_restriction.sh # 然后输入 /home/wwwroot/你的域名/public
安装 radius
, 不使用VPN的话, 可以不进行这一步
# 先安装perl apt-get install perl # 然后需要安装perl的DBI组件 perl -MCPAN -e shell cpan>install DBI //安装完成后退出cpan cpan>quit # 再安装其它组件 apt install freeradius freeradius-mysql freeradius-utils
配置数据库
浏览器打开 http://你的vps ip/phpmyadmin
用户 : root
密码 :安装 lnmp 时设置的
需要创建一个数据库和一个访问这个数据库的用户
点击 用户 -> 新建 -> 添加用户
登录信息 :
Username 选择 使用文本域 , 填写你的用户名 如 sspanel
Host 选择任意主机 %
密码 选择使用文本域 填写密码
用户数据库 :
勾选 创建与用户同名的数据库并授予所有权限
全局权限 :
全选
接着按执行 选择刚刚新建的数据库 sspanel 导入程序目录下的 glzjin_all.sql
不适用 VPN 的话跳下一步
接着配置 radius , 创建个 radius 数据库和用户 (重复以上步骤)
选择 radius 数据库 导入 https://github.com/glzjin/Radius-install/raw/master/all.sql
回到 ssh 继续设置 radius
编辑 /etc/freeradius/sql.conf
配置 login(用户名), password(密码), radius_db(数据库名)等字段
找到 readclients 一行,设为 yes 并去掉注释符号#
DEBIAN8还需要修改/etc/freeradius/radiusd.conf
去掉$INCLUDE sql.conf
和 $INCLUDE sql/mysql/counter.conf
前面的 #
其他系统可以尝试直接覆盖文件
wget https://github.com/glzjin/Radius-install/raw/master/radiusd.conf -O /etc/freeradius/radiusd.conf
然后下面是几个文件的覆盖
wget https://github.com/glzjin/Radius-install/raw/master/default -O /etc/freeradius/sites-enabled/default wget https://github.com/glzjin/Radius-install/raw/master/dialup.conf -O /etc/freeradius/sql/mysql/dialup.conf wget https://github.com/glzjin/Radius-install/raw/master/dictionary -O /etc/freeradius/dictionary wget https://github.com/glzjin/Radius-install/raw/master/counter.conf -O /etc/freeradius/sql/mysql/counter.conf
Radius 配置完成,
service freeradius start
然后你也可以将该 freeradius 设为开机启动项
systemctl enable freeradius
注意:配置freeradius可能导致mysql无法启动,此时只需要删除 /etc/mysql/my.cnf
即可。
配置 sspanel
cd /home/wwwroot/你的域名
php composer.phar install
cp config/.config.php.example config/.config.php
# 编辑以下文件 建议使用 FTP 下载到本地修改
vi config/.config.php
由于配置太多 这里只说重点
$System_Config['key'] = ''; //修改此key为随机字符串确保网站安全 $System_Config['appName'] = ''; //站点名称 $System_Config['baseUrl'] = 'https://zhaojin97.cn'; // 站点地址 $System_Config['timeZone'] = 'PRC'; // RPC 天朝时间 UTC 格林时间 $System_Config['pwdMethod'] = 'sha256'; // 密码加密 可选 md5,sha256 $System_Config['salt'] = ''; // 密码加密用,从旧版升级请留空 $System_Config['authDriver'] = 'cookie'; // 登录验证存储方式,推荐使用Redis 可选: cookie,redis $System_Config['mailDriver'] = 'mailgun'; // 邮件 可选 mailgun or smtp 需要支持qq邮箱的选 smtp $System_Config['checkinMin'] = '100'; // 签到最少流量 单位MB $System_Config['checkinMax'] = '500'; // 签到最多流量 $System_Config['defaultTraffic'] = '100'; // 用户初始流量 单位GB $System_Config['inviteNum'] = '0'; // 注册后获得的邀请码数量 # database 数据库配置 $System_Config['db_driver'] = 'mysql'; $System_Config['db_host'] = 'localhost'; // 数据库地址 $System_Config['db_database'] = ''; // 数据库名称 sspanel $System_Config['db_username'] = ''; // 数据库用户 sspanel $System_Config['db_password'] = ''; // sspanel用户的密码 $System_Config['db_charset'] = 'utf8'; $System_Config['db_collation'] = 'utf8_general_ci'; $System_Config['db_prefix'] = ''; # redis $System_Config['redis_scheme'] = 'tcp'; // 登录验证存储方式选了 redis 的话需要配置 $System_Config['redis_host'] = '127.0.0.1'; $System_Config['redis_port'] = '6379'; $System_Config['redis_database'] = '0'; $System_Config['redis_password']=""; # smtp $System_Config['smtp_host'] = ''; // 例如 smtp.qq.com $System_Config['smtp_username'] = ''; $System_Config['smtp_port'] = '25'; $System_Config['smtp_name'] = ''; $System_Config['smtp_sender'] = ''; $System_Config['smtp_passsword'] = ''; $System_Config['smtp_ssl'] = 'false'; #功能开关 需要用到的才开 建议先别动 $System_Config['enable_wecenter']='false'; $System_Config['enable_radius']='false'; // 配置了 radius 的话就开 $System_Config['enable_cloudxns']='false'; $System_Config['enable_duoshuo']='false'; $System_Config['enable_rss']='true'; $System_Config['enable_paymentwall']='false'; #Radius数据库设置 $System_Config['radius_db_host']=''; // 跟 上面 database 数据库配置差不多 换成radius即可 $System_Config['radius_db_database']=''; $System_Config['radius_db_user']=''; $System_Config['radius_db_password']=''; #Radius连接密钥 $System_Config['radius_secret']=''; // 这个重要 必须设 #端口池 $System_Config['min_port']='10000'; // SSR 分配端口号范围 $System_Config['max_port']='65535'; #两种方式相对于ss端口的偏移 $System_Config['pacp_offset']='-20000'; // PAC+ 和 PAC++ 用到 $System_Config['pacpp_offset']='-20000'; #测速周期/h $System_Config['Speedtest_duration']='6'; // 对应后端 SSR 的 userapiconfig.py 里的 SPEEDTEST #随机分组,注册时随机分配到的分组,多个分组请用英文半角逗号分隔。 $System_Config['ramdom_group']='0'; // 组别用于区分用户组 对应组只能访问对应组和0组的服务器 明白后再修改 #充值返利百分比 $System_Config['code_payback']='20'; // 用户充值后 给邀请他注册的人返利多少% #注册时的流量重置日以及需要重置的流量,0不重置 $System_Config['reg_auto_reset_day']='0'; $System_Config['reg_auto_reset_bandwidth']='100'; // 单位G
redis设置
如果要使用redis,则执行以下操作。
安装redis
apt-get install redis-server
修改/etc/redis/redis.conf
找到requirepass
开头的行,并去掉#
,设置一个密码,并将密码填入.config.php
相应的行中。
以上的操作做完之后。
在你的网站目录下执行以下命令创建管理员
php xcat createAdmin
按照提示, 输入管理员邮箱密码等信息, 然后执行以下命令同步用户
php xcat syncusers
此时管理员创建完成
接下来需要对服务器进行计划任务的设置,执行 crontab -e 命令, 添加以下五段
30 22 * * * php /home/wwwroot/站点文件夹/xcat sendDiaryMail //发送每日邮件,如果不需要这个功能可以不添加这段。 */1 * * * * php /home/wwwroot/站点文件夹/xcat synclogin */1 * * * * php /home/wwwroot/站点文件夹/xcat syncvpn 0 0 * * * php /home/wwwroot/站点文件夹/xcat dailyjob */1 * * * * php /home/wwwroot/站点文件夹/xcat checkjob */1 * * * * php /home/wwwroot/站点文件夹/xcat syncnas
注意事项
检查时间是否为天朝时间
如果VPS默认是非中国时区的话, 如下命令可以用来更改为中国时区
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
检查防火墙是否屏蔽数据库端口
# 允许本机访问 iptables -A INPUT -s 127.0.0.1/32 -p tcp -m tcp --dport 3306 -j ACCEPT # 允许节点访问 iptables -A INPUT -s 节点IP -p tcp -m tcp --dport 3306 -j ACCEPT # 允许所有IP访问 iptables -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
查看防火墙规则
查看已添加的iptables规则 iptables -L -n --line-numbers 删除已添加的iptables规则 iptables -D INPUT line-numbers
规则保存
# Ubuntu iptables-save > /etc/iptables.rules # CentOS service iptables save
CDN环境下获取访客的真实IP
如果前端面板套用了CDN,那么在后台看到的访客地址将是来自于CDN节点的访客地址,为了解决这个问题,需要启用NGINX的realip模块,具体内容参考,这里是以CLOUDFLARE为例,如果需要使用其他CDN,请查看你的CDN服务商的IP地址范围并替换就好了。
屏蔽搜索引擎
因为网站的特殊性,所以可能需要屏蔽搜索引擎的索引。把以下内容添加到nginx的配置中
vi /usr/local/nginx/conf/vhost/你的域名.conf
添加以下内容到server段,并重启nginx
if ($http_user_agent ~* (baiduspider|googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)) { return 403; }
结束
前端的部分就到这里,之后我会更新后端的部分。
原文链接:安装说明