Operations 8 min read

How to Deploy Yapi API Management Platform on CentOS: Step‑by‑Step Guide

This article provides a comprehensive, step‑by‑step tutorial for installing and configuring the Yapi API management platform on a CentOS 7.6 server, covering system prerequisites, Node.js and MongoDB setup, environment configuration, deployment commands, and common error troubleshooting.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Deploy Yapi API Management Platform on CentOS: Step‑by‑Step Guide

1. Yapi Overview

Yapi is a high‑efficiency, easy‑to‑use API management platform designed for developers, product managers and testers to provide elegant interface management services.

Key features include visual interface management, data mocking, automated interface testing, data import (Swagger, HAR, Postman, JSON, CLI), permission management, support for local deployment, plugins, and secondary development.

2. System Environment

OS version: CentOS 7.6

MongoDB version: 3.2.22

Node.js version: 9.8.0

Git version: 1.8.3

3. System Environment Configuration

1) Configure Alibaba Cloud yum repository:

cat > /etc/yum.repos.d/CentOS-Base.repo << EOF
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
EOF

2) Disable and stop firewalld:

systemctl disable firewalld && systemctl stop firewalld

3) Temporarily and permanently disable SELinux:

setenforce 0

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

4) Flush iptables rules:

iptables -X && iptables -F && iptables -Z

4. Deploy Node.js Environment

1) Download and extract Node.js 9.8.0:

cd /opt

wget https://nodejs.org/dist/v9.8.0/node-v9.8.0-linux-x64.tar.xz
xz -d node-v9.8.0-linux-x64.tar.xz
tar -xf node-v9.8.0-linux-x64.tar

2) Create symbolic links:

cd node-v9.8.0-linux-x64
ln -s /opt/node-v9.8.0-linux-x64/bin/node /usr/local/bin/node
ln -s /opt/node-v9.8.0-linux-x64/bin/npm /usr/local/bin/npm

3) Verify versions and switch npm registry:

node -v
npm -v
npm config set registry https://registry.npm.taobao.org

5. Deploy Git

yum install git -y

6. Install and Deploy MongoDB

1) Add MongoDB repository:

cat >> /etc/yum.repos.d/mongodb-org.repo <<EOF
[mongodb-org]
name=MongoDB Repository
baseurl=http://mirrors.aliyun.com/mongodb/yum/redhat/7Server/mongodb-org/3.2/x86_64/
gpgcheck=0
enabled=1
EOF

2) Install MongoDB: yum install -y mongodb-org 3) Modify configuration to listen on all interfaces: sed -i s/127.0.0.1/0.0.0.0/g /etc/mongod.conf 4) Enable service at boot and start:

chkconfig mongod on
systemctl start mongod

5) Verify port 27017 is listening:

ss -tunl | grep 27017

7. Install and Deploy Yapi

npm install -g yapi-cli --registry https://registry.npm.taobao.org
/opt/node-v9.8.0-linux-x64/bin/yapi server

Follow the command‑line prompts, then access the deployment page in a browser at http://{IP}:{PORT} (default port 3000). Provide company name, deployment path, admin email, and other required information.

8. Common Errors and Fixes

If “Cannot find module 'fs‑extra'” appears, run: npm install --save fs-extra If “Cannot find module 'nodemailer'” appears, run: npm install nodemailer --save For MongoDB deprecation warning, add in /etc/my-yapi/vendors/server/utils/db.js line 19: mongoose.set('useUnifiedTopology', true); If “init.lock file already exists” error occurs, remove the lock file: rm -y init.lock If duplicate admin account error occurs, delete the admin user from the database:

mongo
use yapi;
db.user.remove({"username":"admin"});

Then rerun the installation script:

node server/install.js

9. Start Service and Access

Start the Yapi server:

cd /etc/my-yapi/vendors
node server/app.js

Open the URL http://{IP}:{PORT} in a browser, log in with the admin credentials displayed in the console.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DevOpsNode.jsMongoDBAPI ManagementYApiCentOS deployment
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.