debian10 安装 yapi

前置条件有下面两个
  1. 安装node并确保 node 版本=> 7.6 目前测试node14 node16 也不满足要求, 目前使用的node版本是10
  2. 安装mongodb并确保 mongodb 版本 => 2.6,请运行 mongo –version 查看版本号
具体安装步骤
  • 运行下面的命令安装 yapi 的引导工具
    npm install -g yapi-cli --registry https://registry.npm.taobao.org
    npm install -g node-gyp
    npm install -g pm2
    yapi server
    
  • 根据命令行提示信息,在浏览器中访问部署页面

  • 选择部署版本 -> 输入公司名称 -> 输入yapi的部署路径 -> 输入管理员邮箱 -> 输入网站端口号 ->输入数据库地址 -> 输入数据库端口 —> 输入数据库名 -> 选择开始部署

  • 初始化管理员账号成功,账号名:”admin@admin.com”,密码:”ymfe.org”部署成功,请切换到部署目录,输入: “pm2 start vendors/server/app.js” 指令启动服务器, 然后在浏览器打开 http://127.0.0.1:3000 访问

  • 下面命令是设置 pm2 命令开机启动

    pm2 startup
    pm2 save
    

参考链接: https://github.com/YMFE/yapi/issues/16 ; https://mp.weixin.qq.com/s/XNntrSbRhOokQivC9Hffwg

ubuntu20.04 初始化脚本

#!/bin/bash

#update soft
apt update && apt upgrade
apt install wget tar curl rsync bzip2 lsof telnet htop screen tree vim gcc tree git make net-tools lrzsz psmisc hwloc gsmartcontrol chrony -y

#时间设置 
timedatectl set-local-rtc 1
timedatectl set-timezone Asia/Shanghai
systemctl start chrony
systemctl enable chrony


cat <<EOF | sudo tee /lib/systemd/system/rc.local.service
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=no
GuessMainPID=no

[Install]
WantedBy=multi-user.target
Alias=rc-local.service
EOF

ln -s /lib/systemd/system/rc.local.service /etc/systemd/system/rc.local.service


cat <<EOF | sudo tee /etc/rc.local
#!/bin/bash
# 将你需要执行的命令写在这里,禁止写入死循环命令

exit 0
EOF

chmod 755 /etc/rc.local

#设置最大打开文件描述符数
cat >> /etc/security/limits.conf <<EOF
*           soft   nofile       65535
*           hard   nofile       65535
EOF

#set ssh
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
systemctl  restart sshd.service


# profile 修改
echo "export HISTTIMEFORMAT=\"%F %T \"" >> /etc/profile
echo "" >> /etc/profile
echo "## 自定义别名" >> /etc/profile
echo "alias c=clear" >> /etc/profile
echo "alias vi=vim" >> /etc/profile
echo "alias dsh='du -hsx * | sort -rh | head -n 10'" >> /etc/profile
sed -i 's/HISTSIZE=1000/HISTSIZE=10000/g' /etc/profile
source /etc/profile