美文网首页
codepush4之linux下配置自己服务器

codepush4之linux下配置自己服务器

作者: IDO0 | 来源:发表于2018-02-01 11:31 被阅读0次

    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
      },
    

    7:
    启动数据库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

    相关文章

      网友评论

          本文标题:codepush4之linux下配置自己服务器

          本文链接:https://www.haomeiwen.com/subject/yptdzxtx.html