3
Yapi 搭建
source link: https://blog.51cto.com/u_12113362/5766709
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Yapi 搭建
精选 原创1.安装 node
# download node package, recommended directory is /usr/local/src/
$ wget https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.xz
# decompression node package
$ xz -d node-v10.13.0-linux-x64.tar.xz
$ tar -xf node-v10.13.0-linux-x64.tar
# create ln files
$ ln -s /usr/local/src/node-v10.13.0-linux-x64/bin/node /usr/bin/node
$ ln -s /usr/local/src/node-v10.13.0-linux-x64/bin/npm /usr/bin/npm
# create npm china registry
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
$ ln -s /usr/local/src/node-v10.13.0-linux-x64/bin/cnpm /usr/bin/cnpm
$ wget https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.xz
# decompression node package
$ xz -d node-v10.13.0-linux-x64.tar.xz
$ tar -xf node-v10.13.0-linux-x64.tar
# create ln files
$ ln -s /usr/local/src/node-v10.13.0-linux-x64/bin/node /usr/bin/node
$ ln -s /usr/local/src/node-v10.13.0-linux-x64/bin/npm /usr/bin/npm
# create npm china registry
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
$ ln -s /usr/local/src/node-v10.13.0-linux-x64/bin/cnpm /usr/bin/cnpm
2.安装mongo
cat > /etc/yum.repos.d << EOF
[mongodb-org]
name=MongoDB Repository
baseurl=https://mirrors.aliyun.com/mongodb/yum/redhat/7/mongodb-org/4.4/x86_64/
gpgcheck=0
enabled=1
yum makecache
yum install -y mongodb-org
mkdir -p /mnt/data/mongo
mkdir -p /mnt/data/mongo/log/
chown mongod:mongod /mnt/data/mongo -R
vim /etc/mongod.conf # 修改以下内容
dbPath: /mnt/data/mongo
path: /mnt/data/mongo/log/mongod.log
bindIp: 0.0.0.0
systemctl start mongod
mongo #进入mongo 数据库
> use yapi
> db.createUser({user:"yapi",pwd:"yapi123456",roles:[{role:"userAdmin",db:"yapi"},{role:"readWrite",db:"yapi"}]})
[mongodb-org]
name=MongoDB Repository
baseurl=https://mirrors.aliyun.com/mongodb/yum/redhat/7/mongodb-org/4.4/x86_64/
gpgcheck=0
enabled=1
yum makecache
yum install -y mongodb-org
mkdir -p /mnt/data/mongo
mkdir -p /mnt/data/mongo/log/
chown mongod:mongod /mnt/data/mongo -R
vim /etc/mongod.conf # 修改以下内容
dbPath: /mnt/data/mongo
path: /mnt/data/mongo/log/mongod.log
bindIp: 0.0.0.0
systemctl start mongod
mongo #进入mongo 数据库
> use yapi
> db.createUser({user:"yapi",pwd:"yapi123456",roles:[{role:"userAdmin",db:"yapi"},{role:"readWrite",db:"yapi"}]})
3.下载安装包并解压
mkdir /opt/yapi/
cd /opt/yapi/
wget https://github.com/YMFE/yapi/archive/refs/tags/v1.10.2.tar.gz
tar xzf yapi-1.10.2.tar.gz
mv yapi-1.10.2 vendors
cd /opt/yapi/
wget https://github.com/YMFE/yapi/archive/refs/tags/v1.10.2.tar.gz
tar xzf yapi-1.10.2.tar.gz
mv yapi-1.10.2 vendors
4.添加配置文件
cd /opt/yapi/
vim config.json
{
"port": "3000",
"closeRegister":true,
"adminAccount": "admin@com",
"timeout":120000,
"db": {
"servername": "*****",
"DATABASE": "yapi",
"port": 27017,
"user": "yapi",
"pass": "yapi123456",
"authSource": ""
},
"mail": {
"enable": true,
"host": "smtp.exmail.qq.com",
"port": 465,
"from": "***",
"auth": {
"user": "***",
"pass": "****"
}
},
"ldapLogin": {
"enable": true,
"server": "ldap://***",
"baseDn": "***",
"bindPassword": "****",
"searchDn": "***",
"searchStandard": "&(objectClass=user)(cn=%s)",
"emailPostfix": "",
"emailKey": "mail",
"usernameKey": "sAMAccountName"
}
}
vim config.json
{
"port": "3000",
"closeRegister":true,
"adminAccount": "admin@com",
"timeout":120000,
"db": {
"servername": "*****",
"DATABASE": "yapi",
"port": 27017,
"user": "yapi",
"pass": "yapi123456",
"authSource": ""
},
"mail": {
"enable": true,
"host": "smtp.exmail.qq.com",
"port": 465,
"from": "***",
"auth": {
"user": "***",
"pass": "****"
}
},
"ldapLogin": {
"enable": true,
"server": "ldap://***",
"baseDn": "***",
"bindPassword": "****",
"searchDn": "***",
"searchStandard": "&(objectClass=user)(cn=%s)",
"emailPostfix": "",
"emailKey": "mail",
"usernameKey": "sAMAccountName"
}
}
5.初始化库表并启动
cd /opt/yapi/vendors
cnpm install
npm run install-server #初始化表库
node server/app.js #启动
cnpm install
npm run install-server #初始化表库
node server/app.js #启动
【Ref】 https://hellosean1025.github.io/yapi/devops/index.html#%e5%ae%89%e8%a3%85
- 打赏
- 赞
- 收藏
- 1评论
- 分享
- 举报
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK