centos上部署rap2

rap2是阿里开源的接口管理平台,最近应公司要求,在公司内网搭建rap2。

后端搭建:

1.环境:

     node.js 8.9.4+
     mysql 5.7+
     redis 4.0+
     centos 6.5(阿里云ECS)

2.项目地址:

     https://github.com/thx/rap2-delos.git

git clone 下载之后,修改这几个文件的配置config.dev.ts、config.local.ts、config.prod.ts,位置在rap2-delos/src/config。三个文件都照如下修改好:

  1. import { IConfigOptions } from "../types";
  2. let config: IConfigOptions =  {
  3.   version: '2.3',
  4.   serve: {
  5.     port: 8888                    //你自己设置的端口,我是设置的8888
  6.   },
  7.   keys: ['some secret hurr'],
  8.   session: {
  9.     key: 'rap2:sess'
  10.   },
  11.   db: {
  12.     dialect: 'mysql',
  13.     host: 'localhost',         //mysql服务器的ip,这里我是用的本地的mysql
  14.     port: 3306,
  15.     username: 'root',       //mysql用户名
  16.     password: 'root',       //mysql密码      
  17.     database: 'RAP2_DELOS_APP',    //rap2的后台数据库名
  18.     pool: {
  19.       max: 5,
  20.       min: 0,
  21.       idle: 10000
  22.     },
  23.     logging: false
  24.   },
  25.   redis:{
  26.     host: 'localhost',      
  27.     port: 6379
  28.   }
  29. }
  30. export default config

3.修改完成之后,在上述配置的数据库上建立rap2的数据库:RAP2_DELOS_APP。
    DROP DATABASE RAP2_DELOS_APP;
    CREATE DATABASE IF NOT EXISTS RAP2_DELOS_APP DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

4.安装依赖
    在项目根目录rap-delos下运行npm install,可能会出现什么gcc版本过低等问题,可百度去升级。

5.初始化数据库
    根目录下运行 npm run create-db,初始化RAP2_DELOS_APP数据库。

6.检查
    npm run check,可以检查项目的配置,代码的正确性。

7.编译
    npm run build,修改了项目的代码之后一定重新编译,不然修改不起作用。

8.运行
    npm run dev
    正常结果截图: 
centos上部署rap2

    浏览器访问效果截图:
centos上部署rap2

前端搭建:

1.下载源码
     git clone https://github.com/thx/rap2-dolores.git

2.修改config.dev.ts的配置,在rap2-dolores/src/config/ 路径下,修改serve对应的值。默认为'localhost:8080',修改成后端服务器的ip(rap2.msq.com)+之前配置的端口(8888);

3.安装依赖 npm install

4.启动项目 npm run dev
    正常启动截图:
centos上部署rap2

5.用nginx指向localhost:3000,我这里设置的rap2.msq.com
    浏览器访问截图:
centos上部署rap2

ps:配置nginx后要修改host:服务器Ip    rap2.msq.com。

参考:https://incoder.org/2018/03/27/rap2/