Skip to content

从master分支升级到new_master分支

iMeiji edited this page Aug 2, 2017 · 2 revisions

从master分支升级到new_master分支

本文是 sspanel v3 魔改版 master 分支升级到 new_master 分支的记录, 如果你是重新搭建的话建议看另一篇安装说明-lnmp1.4, 如果你正在使用 master 分支并且想升级的话建议看下本文...

版本跨越: 最新 master 分支---> 2017-07-18 new_master 分支

提醒:升级之前建议你备份数据库和.config.php文件(在/home/wwwroot/你的域名/config)

升级数据库

连接到旧数据库,然后执行以下的 SQL 语句(可以在phpMyAdmin里操作)

CREATE TABLE `telegram_session` ( `id` BIGINT NOT NULL AUTO_INCREMENT , `user_id` BIGINT NOT NULL , `type` INT NOT NULL , `session_content` TEXT NOT NULL , `datetime` BIGINT NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;

ALTER TABLE `user` ADD `telegram_id` BIGINT NULL AFTER `is_multi_user`; 

CREATE TABLE IF NOT EXISTS `paylist` (
  `id` bigint(20) NOT NULL,
  `userid` bigint(20) NOT NULL,
  `total` decimal(12,2) NOT NULL,
  `status` int(11) NOT NULL DEFAULT '0',
  `tradeno` text,
  `datetime` bigint(20) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `paylist`
--
ALTER TABLE `paylist`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `paylist`
--
ALTER TABLE `paylist`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;ALTER TABLE `user_traffic_log` CHANGE `u` `u` BIGINT(20) NOT NULL, CHANGE `d` `d` BIGINT(20) NOT NULL;

升级前端

cd /home/wwwroot/你的域名
git pull
git checkout new_master -f

没发生错误的可以直接看下一步,有错误的继续看,这里引用赵大的原话

面板自己修改之后如何跟进更新

以下假设你能看得懂命令执行以后的英文提示。

因为各种各样的原因,面板并不能满足所有人的需求,那么可能这时候就想自己来继续改一改来符合自己的要求了。 自己修改过之后,执行 git pull 时候你可能会遇到些错误提示,提示操作不能继续进行。

这时候,你就要

git add .

来添加你修改的文件,

再然后

git commit -m "something you'd like to say"

来“提交”你的更改。放心,这里只是将您的修改纳入版本管理系统,不会真正提交上去。

再然后,就可以 git pull 了。

然而事与愿违,有时候更新的地方刚好和你修改的地方冲突了,你 git pull 时候还会受阻。

那么这时候,你就需要 git status 看一看哪些文件冲突了,再然后,去打开那些文件,主要看到被

<<<<<<<<<
之前的
==========
之后的
>>>>>>>>>>

这样包裹的段落,然后把整个按照实际情况修改为自己想要的。

处理完冲突之后 git add 再 git commit -m "something" 一下就完成了。

配置前端

先更新依赖

cd /home/wwwroot/你的域名
php composer.phar install

然后编写配置

cp config/.config.php.example config/.config.php

升级后端

这里引用 wiki 好了 , 很简单

此版本添加了 HTTP API。

您可以让后端用这个方式与面板进行沟通了,相比起之前的 MYSQL,稳定许多。

git pull 之后,来讲讲如何设置。

打开 userapiconfig.py 将 API_INTERFACE 这个参数改为 modwebapi

API_INTERFACE = 'modwebapi'

同时您需要添加以下两项来设置 HTTP API

WEBAPI_URL = 'https://zhaoj.in'

WEBAPI_TOKEN = 'glzjin'

第一项为您网站的地址,请按照上面这个格式输入地址,第二项为 token,为您网站 config/.config.php 内 muKey 的值。

然后保存之后,请按装 python ssl 所需的相关依赖,

以 Centos 6 为例,其他系统大同小异,主要就是安装所需要的依赖。

yum -y install python-devel

yum -y install libffi-devel

yum -y install openssl-devel

然后在后端目录下

pip install -r requirements.txt

安装完依赖之后,就可以重启后端了。

Ubuntu 执行这个

apt-get install libssl-dev python-dev libffi-dev
pip install -r requirements.txt

测试通讯:

curl 站点地址/mod_mu/func/ping?key=WEBAPI_TOKEN

其中 WEBAPI_TOKEN 为您网站 config/.config.php 内 muKey 的值

有返回pong就表明可以正常通讯了

补充:

  1. 如果用 lnmp 那个一件包安装的话,可以把 nginx 配置 /usr/local/nginx/conf/nginx.conf

    的 keepalive_timeout 从 60 改成 75,避免和 http api 同步周期撞上,从而需要频繁地建立连接。

  2. 面板会验证 api 请求的来源 IP 是否为节点 IP,如果用了 CDN,记得想办法把正确的 IP 传到面板上,比如用 nginx 的 real_ip 模块,这里简单说下 LNMP 重新安装 nginx 并开启real_ip 模块。

    在 lnmp 安装目录下找到 lnmp.conf 编辑它,在 Nginx_Modules_Options 里加上 realip ,如下所示:

    Nginx_Modules_Options='--with-http_realip_module'

    保存后执行 ./upgrade.sh nginx 来升级下 nginx 就可以了。

    然后编辑 nginx 配置

    vi /usr/local/nginx/conf/nginx.conf

    在 http 里添加以下内容

    set_real_ip_from 103.21.244.0/22;
    set_real_ip_from 103.22.200.0/22;
    set_real_ip_from 103.31.4.0/22;
    set_real_ip_from 104.16.0.0/12;
    set_real_ip_from 108.162.192.0/18;
    set_real_ip_from 131.0.72.0/22;
    set_real_ip_from 141.101.64.0/18;
    set_real_ip_from 162.158.0.0/15;
    set_real_ip_from 172.64.0.0/13;
    set_real_ip_from 173.245.48.0/20;
    set_real_ip_from 188.114.96.0/20;
    set_real_ip_from 190.93.240.0/20;
    set_real_ip_from 197.234.240.0/22;
    set_real_ip_from 198.41.128.0/17;
    set_real_ip_from 199.27.128.0/21;
    set_real_ip_from 2400:cb00::/32;
    set_real_ip_from 2606:4700::/32;
    set_real_ip_from 2803:f800::/32;
    set_real_ip_from 2405:b500::/32;
    set_real_ip_from 2405:8100::/32;
    set_real_ip_from 2c0f:f248::/32;
    set_real_ip_from 2a06:98c0::/29;
    
    # use any of the following two
    # real_ip_header CF-Connecting-IP;
    real_ip_header X-Forwarded-For;
    real_ip_recursive on;
    
  3. 如果使用 nginx 的 real_ip 模块依旧报错, 面板验证不了请求来源的 IP, 这时候就需要修改 hosts 文件

    vi /etc/hosts
    # 添加你的面板IP 和 网站域名 如:
    1.2.3.4		ss.panel
    
  4. 如果您要使用这个对用户友好的审计规则阻断页面功能,请在 user-config.json 中将 friendly_detect 设置为 1(没有这个设置就自己添加一个),然后试着访问某个在审计规则里的 http 网页就可以看到效果了。当然目前仅对访问 80 端口的 http 请求有效。

    如果您想自定义这个阻断页面的内容,可以复制 detect.html 为 user-detect.html 然后修改 user-detect.html ,重启后端即可自定义。