关于CentOS YAPI部署(代码分享)
时间:2021-09-17
来源:互联网
标签:
今天PHP爱好者给大家带来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/mongo
chown -R mongod:mongod /var/log/mongodb
chown mongod:mongod /tmp/*.sock
yapi安装配置
wget https://github.com/YMFE/yapi/archive/refs/tags/v1.9.3.tar.gz
tar -zxvf v1.9.3.tar.gz
mv yapi-1.9.3 yapi
cd yapi
cp config_example.json config.json
把默认的数据库链接配置干掉
vi config.json
db:{
- user:'test',
- pass:'test'
}
初始化
# 初始化 依赖
npm install --production --registry https://registry.npm.taobao.org
# 初始化数据库
npm run install-server
# 启动
node server/app.js
#or
pm2 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 YAPI部署(代码分享)的详细内容,更多请关注php爱好者其它相关文章!
-
如何注册谷歌账号(谷歌账号注册方法) 怎么跳过手机验证 时间:2025-09-29
-
access数据库8个经典实例 时间:2025-09-29
-
mmc.exe是什么进程 mmc.exe应用程序错误的原因及解决方法 时间:2025-09-29
-
4种基本的编程命名规范介绍(匈牙利命名法、驼峰式命名法、帕斯卡命名法、下划线命名法) 时间:2025-09-29
-
Ghostscript下载、安装教程 Ghostscript命令参数详解 时间:2025-09-29
-
Linux中内存管理NUMA架构详解 时间:2025-09-29
今日更新
-
币安Bitget交易所指南 主流数字货币投资最佳入口
阅读:18
-
塔科夫的梗是什么梗?揭秘玩家最爱用的搞笑黑话真相
阅读:18
-
币安Bit-Z交易所:全球加密资产交易平台 安全便捷买卖数字货币
阅读:18
-
币安Bithumb韩国交易所指南 主流平台推荐与对比
阅读:18
-
想知道塔塞是什么梗?揭秘网络热词塔塞的由来和爆火原因,快来看看吧!
阅读:18
-
币安Biki交易所APP下载 多币种投资交易平台
阅读:18
-
塔寨村是什么梗?揭秘破冰行动原型村的网络爆火真相
阅读:18
-
币安BigOne交易平台上线 安全交易数字货币首选
阅读:18
-
新兴加密交易平台推荐:币安与AVIVE交易所APP优势解析
阅读:18
-
塔寨是什么梗揭秘其爆火原因及背后有趣故事快来了解
阅读:18