一,环境需要
二,更新yum 源 gcc-c++
[root@localhost ~]# yum update
[root@localhost ~]# yum install gcc-c++
三,安装node.js
[root@localhost ~]# curl -sL https://rpm.nodesource.com/setup_8.x | bash -
[root@localhost ~]# yum install -y nodejs
[root@localhost ~]# node -v
v8.16.1
[root@localhost ~]# npm -v
6.4.1
[root@localhost ~]# yum -y update
四,安装mongodb
[root@localhost ~]# touch /etc/yum.repos.d/mongodb-org.repo
[root@localhost ~]# vim /etc/yum.repos.d/mongodb-org.repo
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
[root@localhost yum.repos.d]# yum install -y mongodb-org
[root@localhost yum.repos.d]# service mongod start
Starting mongod (via systemctl): [ 确定 ]
[root@localhost yum.repos.d]# chkconfig mongod on
[root@localhost yum.repos.d]# find / -name mongod.conf
/etc/mongod.conf
[root@localhost yum.repos.d]# vim /etc/mongod.conf
注释掉:#bindIp: 127.0.0.1
[root@localhost yum.repos.d]# service mongod restart
Restarting mongod (via systemctl): [ 确定 ]
五,安装git
[root@localhost yum.repos.d]# yum -y install git
六,安装 YApi
[root@localhost yum.repos.d]# npm install -g yapi-cli --registry https://registry.npm.taobao.org
[root@localhost yum.repos.d]# yapi server
在浏览器打开 http://0.0.0.0:9090 访问。非本地服务器,请将 0.0.0.0 替换成指定的域名或ip
初始化管理员账号成功,账号名:"[email protected]",密码:"ymfe.org"
部署成功,请切换到部署目录,输入: "node vendors/server/app.js" 指令启动服务器,
然后在浏览器打开 http://127.0.0.1:3000 访问
七,启动
[root@localhost ~]# cd /etc/yum.repos.d/my-yapi
[root@localhost my-yapi]# node vendors/server/app.js
log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
log: 服务已启动,请打开下面链接访问:
http://127.0.0.1:3000/
log: mongodb load success...
八,安装成功
九,后台运行
我的yapi是安装在/etc/yum.repos.d/my-yapi
启动执行: pm2 start /etc/yum.repos.d/my-yapi/vendors/server/app.js
关闭执行: pm2 stop /etc/yum.repos.d/my-yapi/vendors/server/app.js
[root@localhost my-yapi]# npm install -g pm2