codepush4之linux下配置自己服务器

codepush热更新
codepush2之配置自己的服务器
codepush3之Android原生引用集成codepush

通过ssh方式远程连接服务器
ssh 用户名@ip
例如:
ssh root@172.28.32.244
用户名:root
密码:123456

服务器配置

1:
通过nvm安装node
安装nvm
参考:https://github.com/creationix/nvm#install-script
nvm ls-remote (查看node版本)
nvm install v8.9.4 (安装某个版本node)
2:
cd /
在/ 目录下 新建app文件夹(mkdir app)
cd app
新建 db目录(mkdir db)
cd db
新建 文件夹data ,storage用于存储更新上传的文件
3:
下载code-push-server
wget https://github.com/lisong/code-push-server/archive/master.zip
4:
解压unzip master.zip
如果没有unzip 安装yum install -y unzip
yum命令:http://www.linuxidc.com/Linux/2016-05/131702.htm
5:
安装数据库
cat /etc/centos-release 查看linux版本
因为我是cenOS7
yum -y install mariadb mariadb-server
6:
启动,配置数据库账号密码
centos7启动和设置mysql/mariadb
7:配置config.js

 db: {
    username: "root",
    password: "123456",
    database: "codepush",
    host: "127.0.0.1",
    port: 3306,
    dialect: "mysql",
    logging: false
  },

 local: {
    // Binary files storage dir, Do not use tmpdir and it's public download dir.
    storageDir: "/app/db/storage",
    // Binary files download host address which Code Push Server listen to. the files storage in storageDir.
    downloadUrl: "http://172.28.32.244:3000/download",
    // public static download spacename.
    public: '/download'
  },
  jwt: {
    //网站获取
    // Recommended: 63 random alpha-numeric characters
    // Generate using: https://www.grc.com/passwords.htm
    tokenSecret: '45E46vA3jqfqwGLfwSyFGa22dmUOvYTTxUpxk8HxqYROKQXdFrIwfeUopkSfXam'
  },

  common: {
    /*
     * tryLoginTimes is control login error times to avoid force attack.
     * if value is 0, no limit for login auth, it may not safe for account. when it's a number, it means you can
     * try that times today. but it need config redis server.
     */
    tryLoginTimes: 0,
    // CodePush Web(https://github.com/lisong/code-push-web) login address.
    //codePushWebUrl: "http://localhost:3001/login",
    // create patch updates's number. default value is 3
    diffNums: 3,
    // data dir for caclulate diff files. it's optimization.
    dataDir: "/app/db/data",
    // storageType which is your binary package files store. options value is ("local" | "qiniu" | "s3")
    storageType: "local",
    // options value is (true | false), when it's true, it will cache updateCheck results in redis.
    updateCheckCache: false
  },

8:
启动数据库mysql -u root -p
startmysql.png

配置数据库:
./bin/db init –dbhost localhost –dbuser root –dbpassword 123456
success.png

启动./bin/www
successcoudpush.png

客户端配置

参考codepush2之配置自己的服务器

错误截图:

1:没有安装unzip
unzip.png
yum -y install unzip

2:config.js db配置错误host应该为”127.0.0.1”
ipbug.png

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值