【Yapi】Yapi在centos7.6下的安装

环境要求

nodejs(7.6+)
mongodb(2.6+)
git(在线安装需要)

nodejs安装

nodejs下载链接:
在这里插入图片描述

1)、#解压Node.js

#***.tar.xz格式文件需要两部解压步骤,

xz -d node-v12.18.4-linux-x64.tar.xz
tar -xvf node-v12.18.4-linux-x64.tar
[root@localhost tmn]# mv node-v12.18.4-linux-x64 nodejs
vi /etc/profile
# Nodejs
export NODEJS_HOME=/app/tmn/nodejs
export PATH=$NODEJS_HOME/bin:$PATH
source /etc/profile
[root@localhost nodejs]# node -v
v12.18.4

mongodb安装

mongodb下载

在这里插入图片描述

[root@localhost tmn]$ tar -xzvf mongodb-linux-x86_64-rhel70-4.4.1.tgz 
mongodb-linux-x86_64-rhel70-4.4.1/LICENSE-Community.txt
mongodb-linux-x86_64-rhel70-4.4.1/MPL-2
mongodb-linux-x86_64-rhel70-4.4.1/README
mongodb-linux-x86_64-rhel70-4.4.1/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-rhel70-4.4.1/bin/install_compass
mongodb-linux-x86_64-rhel70-4.4.1/bin/mongo
mongodb-linux-x86_64-rhel70-4.4.1/bin/mongod
mongodb-linux-x86_64-rhel70-4.4.1/bin/mongos
mv mongodb-linux-x86_64-rhel70-4.4.1 mongodb

/etc/profile添加如下内容

#mongodb
export MONGODB_HOME=/app/tmn/mongodb
export PATH=$MONGODB_HOME/bin:$PATH
[tmn@localhost node-global]$ mongo -version
MongoDB shell version v4.4.1
Build Info: {
    "version": "4.4.1",
    "gitVersion": "ad91a93a5a31e175f5cbf8c69561e788bbc55ce1",
    "openSSLVersion": "OpenSSL 1.0.1e-fips 11 Feb 2013",
    "modules": [],
    "allocator": "tcmalloc",
    "environment": {
        "distmod": "rhel70",
        "distarch": "x86_64",
        "target_arch": "x86_64"
    }
}
[tmn@localhost node-global]$ 

创建yapi的mongodb用户

#链接mongo
mongo
#切换yapi库
use yapi
#新建用户
db.createUser({
user: "yapi",

pwd: "yapi",

roles: [{role: "dbOwner",db: "yapi"}]

})

日志如下:

[tmn@localhost vendors]$ mongo
MongoDB shell version v4.4.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("b3f7ffe2-b279-4ed2-bb15-7c520e8c14dc") }
MongoDB server version: 4.4.1
---
The server generated these startup warnings when booting: 
        2020-09-17T17:39:58.709+08:00: ***** SERVER RESTARTED *****
        2020-09-17T17:40:01.306+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
        2020-09-17T17:40:01.307+08:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
        2020-09-17T17:40:01.307+08:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'
---
---
        Enable MongoDB's free cloud-based monitoring service, which will then receive and display
        metrics about your deployment (disk utilization, CPU, operation statistics, etc).

        The monitoring data will be available on a MongoDB website with a unique URL accessible to you
        and anyone you share the URL with. MongoDB may use this information to make product
        improvements and to suggest MongoDB products and deployment options to you.

        To enable free monitoring, run the following command: db.enableFreeMonitoring()
        To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
> use yapiuse yapi
switched to db yapi
> db.createUser({db.createUser({
... user: "yapi",user: "yapi",
... 
... pwd: "yapi",pwd: "yapi",
... 
... roles: [{role: "dbOwner",db: "yapi"}]roles: [{role: "dbOwner",db: "yapi"}]
... 
... })})
Successfully added user: {
        "user" : "yapi",
        "roles" : [
                {
                        "role" : "dbOwner",
                        "db" : "yapi"
                }
        ]
}
> ^C
bye
[tmn@localhost vendors]$ 

yapi安装

官方介绍

mkdir yapi
cd yapi
git clone https://github.com/YMFE/yapi.git vendors //或者下载 zip 包解压到 vendors 目录(clone 整个仓库大概 140+ M,可以通过 `git clone --depth=1 https://github.com/YMFE/yapi.git vendors` 命令减少,大概 10+ M)
cp vendors/config_example.json ./config.json //复制完成后请修改相关配置
cd vendors
npm install --production --registry https://registry.npm.taobao.org
npm run install-server //安装程序会初始化数据库索引和管理员账号,管理员账号名可在 config.json 配置
node server/app.js //启动服务器后,请访问 127.0.0.1:{config.json配置的端口},初次运行会有个编译的过程,请耐心等候

由于我是内网linux,所以里面几步不一样说明下,
1.git clone https://github.com/YMFE/yapi.git vendors
这步可以用一台有外网机器复制出来拷到服务器
2.npm install --production --registry https://registry.npm.taobao.org
这步同理,本地会生成node_modules文件夹,将它拿到yapi/vender目录下就行

pm2安装

推荐使用 pm2 管理 node 服务器启动,
参考官方教程
pm2安装
由于本机离线,同样npm install -g pm2
然后把文件夹拿到服务器

ln -s /app/tmn/nodejs/lib/node_modules/pm2/bin/pm2 /usr/bin/pm2

启动

[tmn@localhost yapi]$ pm2 start /app/tmn/yapi/vendors/server/app.js
[PM2] Starting /app/tmn/yapi/vendors/server/app.js in fork_mode (1 instance)
[PM2] Done.
┌─────┬────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name   │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ app    │ default     │ 1.9.2   │ fork    │ 30270    │ 0s     │ 0    │ online    │ 0%       │ 12.6mb   │ tmn      │ disabled │
└─────┴────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[tmn@localhost yapi]$ ps -ef|grep yapi
tmn      30270 30193 47 22:03 ?        00:00:02 node /app/tmn/yapi/vendors/server/app.js
tmn      30296 30124  0 22:04 pts/2    00:00:00 grep --color=auto yapi
[tmn@localhost yapi]$ curl 127.0.0.1:3000
<!DOCTYPE html>
<html>
<head>
<meta  id="cross-request-sign"  charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="keywords" content="yapi接口管理,api管理,接口管理,api,接口,接口文档,api文档,接口管理系统" />
<meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 API,YApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。" />
<title>YApi-高效、易用、功能强大的可视化接口管理平台</title>
<link rel="icon" type="image/png" sizes="192x192" href="/image/favicon.png">
<script>
    document.write('<script src="/prd/assets.js?v=' + Math.random() + '"><\/script>');
</script>

<script>
    document.write('<link rel="stylesheet"  href="/prd/' + window.WEBPACK_ASSETS['index.js'].css + '" />');
</script>

</head>
<body>
<div id="yapi" style="height: 100%;"></div>


<script>
    document.write('<script src="/prd/' + window.WEBPACK_ASSETS['manifest'].js + '"><\/script>');
</script>
<script>
    document.write('<script src="/prd/' + window.WEBPACK_ASSETS['lib3'].js + '"><\/script>');
</script>
<script>
    document.write('<script src="/prd/' + window.WEBPACK_ASSETS['lib2'].js + '"><\/script>');
</script>
<script>
    document.write('<script src="/prd/' + window.WEBPACK_ASSETS['lib'].js + '"><\/script>');
</script>

<script>
    document.write('<script src="/prd/' + window.WEBPACK_ASSETS['index.js'].js + '"><\/script>');
</script>
</body>
</html>
[tmn@localhost yapi]$ 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

实施工程师木易

感谢支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值