【记录】ubuntu下安装和部署RAP2
ubuntu下安装和部署RAP2
1. 后台部署
1.1 安装mysql和redis
$ sudo apt update
$ sudo apt install mysql-server
$ sudo apt install redis-server
1.2 安装pandoc
1.2.1 从pandoc release下载页面下载最新版本
$ wget https://github.com/jgm/pandoc/releases/download/3.1/pandoc-3.1-1-amd64.deb
1.2.2 安装
$ sudo dpkg -i pandoc-3.1-1-amd64.deb
$ pandoc -v
pandoc 3.1
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/ubuntu/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
1.3 安装nodejs和npm
$ sudo apt install nodejs npm
1.4 创建数据库
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \\g.
...mysql> CREATE DATABASE IF NOT EXISTS RAP2_DELOS_APP DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected, 2 warnings (0.07 sec)mysql> show databases;
+--------------------+
| Database |
+--------------------+
| RAP2_DELOS_APP |
...
1.5 初始化
1.5.1 下载rap2-delos并安装依赖软件包
$ git clone https://github.com/thx/rap2-delos.git
...
$ cd rap2-delos
$ npm install
1.5.2 修改项目配置
根据需要修改src/config/config.{ENV}.ts
中对应的数据库配置信息。
1.5.3 安装typescript
sudo npm install -g typescript
npm run build
1.5.4 初始化数据库
$ npm run create-db> rap2-delos@2.9.0 create-db /home/ubuntu/mysites/rap/rap2-delos
> cross-env NODE_ENV=development node dist/scripts/initSchema----------------------------------------
DATABASE √HOST localhostPORT 3306DATABASE RAP2_DELOS_APP
----------------------------------------
成功初始化 DB Schema
1.6 启动后台服务
1.6.1 开发模式下启动
$ npm run dev
> rap2-delos@2.9.0 dev /home/ubuntu/mysites/rap/rap2-delos
> cross-env NODE_ENV=development nodemon --watch scripts --watch dist dist/scripts/dev.js[nodemon] 2.0.21
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): scripts dist//*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node dist/scripts/dev.js`
Starting task: locker check
----------------------------------------
rap2-delos is running as http://localhost:8080
----------------------------------------
DATABASE √HOST localhostPORT 3306DATABASE RAP2_DELOS_APP
----------------------------------------
1.6.2 生产模式下启动
$ npm run build
$ npm start
2. 前端部署
2.1 下载前端代码库
$ git clone https://github.com/thx/rap2-dolores.git
...
$ cd rap2-delores
2.2 安装并生成前段静态文件
$ npm install
$ npm run build