您的位置 首页 centos

关于CentOS YAPI部署(代码分享)

之前的文章《解决uni-app入坑集合的一种方案(分享)》中,给大家介绍了怎么解决uni-app入坑集合。下面本篇文章给大家介绍CentOS YAPI部署,伙伴们来看看一下。

YAPI部署(centos)

环境

Node + mongodb

git

yum install git.

node

yum install nodejs

pm2

npm i -g pm2

mongodb安装配配置

url : https://www.mongodb.com/try/download/community

# 下载wget https://repo.mongodb.org/yum/redhat/8/mongodb-org/5.0/x86_64/RPMS/mongodb-org-server-5.0.0-1.el8.x86_64.rpm# 安装rpm -i mongodb-org-server-5.0.0-1.el8.x86_64.rpm# 启动服务systemctl start mongod.service## 无法启动 给权限chown -R mongod:mongod /var/lib/mongochown -R mongod:mongod /var/log/mongodbchown mongod:mongod /tmp/*.sock

yapi安装配置

wget https://github.com/YMFE/yapi/archive/refs/tags/v1.9.3.tar.gztar -zxvf v1.9.3.tar.gzmv yapi-1.9.3 yapicd yapicp config_example.json  config.json

把默认的数据库链接配置干掉

vi config.jsondb:{  - user:'test',  - pass:'test'}

初始化

# 初始化 依赖npm install --production --registry https://registry.npm.taobao.org# 初始化数据库npm run install-server# 启动node server/app.js   #orpm2 start server/app.js --name yapi

禁止注册

{  "port": "*****",  "closeRegister":true}

外网部署之后1.9.2以下版本有上传 提权漏洞,应该干掉注册

nginx安装配置

yum install nginx
vi /etc/nginx/conf.d/yapi.conf

绑定域名做转发

server{  server_name xxxx.com;  #cache  location ~* \.(?:jpg|jpeg|png|gif|ico|css|js)$ {    proxy_pass http://127.0.0.1:3000;    proxy_redirect  off;     proxy_set_header Host  $host;    expires 365d;    add_header Cache-Control "public";   }  location / {    proxy_http_version 1.1;    proxy_set_header Upgrade $http_upgrade;    proxy_set_header Connection "upgrade";    proxy_pass http://127.0.0.1:3000;    proxy_redirect  off;    proxy_set_header        HOST  $host;    proxy_set_header        X-Real-IP       $remote_addr;    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;    proxy_send_timeout      300;    proxy_read_timeout      300;    add_header Last-Modified $date_gmt;    add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';    if_modified_since off;    expires off;    etag off;  }  #https  #listen 443 ssl;  #ssl_certificate/etc/nginx/cer/fullchain.crt;  #ssl_certificate_key /etc/nginx/cer/private.pem;  #ssl_protocols TLSv1.1 TLSv1.2;  #ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;  #ssl_prefer_server_ciphers on;  #ssl_session_cache shared:SSL:10m;  #ssl_session_timeout 10m;}#server{#  if ($host = xxxx.com) {#      return 301 https://$host$request_uri;#  } ##  server_name xxxx.com;#  listen 80;#  return 404;#

完工!

推荐学习:CentOS入门教程

文章来源:智云一二三科技

文章标题:关于CentOS YAPI部署(代码分享)

文章地址:https://www.zhihuclub.com/9350.shtml

关于作者: 智云科技

热门文章

网站地图