# 飞牛OS部署

> 部署前提示： 飞牛云本质上是一个debain系统，所以项目配置与[部署文档](https://github.com/QingHeYang/EasyAccounts/blob/gh-pages/deploy/deploy.md)基本一致，只是在构建部分有所不同，所以请先阅读[部署文档](https://github.com/QingHeYang/EasyAccounts/blob/gh-pages/deploy/deploy.md)

## 项目准备

> 1. 项目文件
> 2. Fnos网页端
> 3. Fnos后端

## 下载并修改项目

1.  下载项目到本地，无论是什么系统，下载完后解压，此操作无需在Fnos上做，可以在windows或者别的操作系统中执行

    ![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-70e9e738b8944f6af77d863bebb39b0f2e9b01e7%2Ffnos-download.png?alt=media)
2. 修改项目内容

* 在 `./Database/`文件夹下创建init文件夹
* **新用户**：将 `./Database/base_sql/yd_jz_base.sql` 复制到`./Database/init`中
* **老用户**：将曾经备份好的数据库sql文件，放到`./Database/init`中修改完的项目结构如下： ![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-b4fe91c388b2b31d1bc789a5cbcbd5431e2d0ece%2Ffnos-folder.png?alt=media)

3. （可选）老用户可以选择将自己的docker-compose.yml替换掉新下载项目的对应compose文件

> Tips:如果使用曾经的项目文件夹也可以，请务必将`./Database/data`文件夹删除掉！！如果项目部署失败，也需要删除掉这个文件夹！

## 上传项目

1.  选择刚才修改好文件夹并上传

    ![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-727fbc0a943348c957615fab72307a16990d9257%2Ffnos-upload.png?alt=media)
2.  上传后结果

    ![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-a7d43d93de756070c905ddaad54c791ba1d58561%2Ffnos-upload-finish.png?alt=media)

## 数据库文件提权

### 去Fnos后台登录

![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-b02870a8c1fa6cdcf6d4f8ae898c713c878f9e95%2Ffnos-backup.png?alt=media)

### 找到自己刚才上传的文件夹的位置

注意文件夹名称可能不是EasyAccounts-main

```
sudo find / -type d -name "EasyAccounts-main" 2>/dev/null 
```

执行过程会要登录密码\
![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-131a453bbe4188a043535090c9e93d9923b08988%2Ffnos-find.png?alt=media)

进入到最后一个`/vol1/1000/EasyAccounts-main`中，前几个也同样可以进去，但是保存位置确实在最后一个

```
cd vol1/1000/EasyAccounts-main  
ll
```

### 提权

```
sudo chown -R 999:999 ./Database/init  
```

执行后进入`Databse`文件夹确认权限

```
ll
```

看到如下则提权成功\
![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-e8039cb671823116ea1a11a9fb5bbc8d73afb35b%2Ffnos-primission.png?alt=media)

## 部署构建

### 部署

回到浏览器\
![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-505dfb6f2db2b583e71f9e33486c1f2fe2905bdb%2Ffnos-docker.png?alt=media) ![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-a420ef4f4d6db754394249d8b2bd6ab28754947e%2Ffnos-choose.png?alt=media) ![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-433f95613c2543e45b4b0137bafab0a7356d3e9a%2Ffnos-compose.png?alt=media)

### 修改compose

* 新用户：(可以访问dockerhub则跳过该步骤)dockerhub访问不畅可以使用国内镜像：\
  将`EasyAccounts/docker-compose-chinese.yml`的内容复制到项目构建框中 ![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-bfe092588a138b610693488782232d5121a2b9b9%2Ffnos-china.png?alt=media)

![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-9226eebe7835000268a8fe1ec02df1fec411ac94%2Ffnos-compose-deploy.png?alt=media)

* 老用户：将自己的compose文件粘贴进入上图的编辑框中即可

按照标准[部署文档](https://github.com/QingHeYang/EasyAccounts/blob/gh-pages/deploy/deploy.md) 修改compose对应的内容，此处不在赘述

### 构建

启动构建\
![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-222cde48b8d0eca07e5e3e327718678cc4556f61%2Ffnos-build.png?alt=media)

当db容器日志中出现如下内容表示数据库成功\
![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-08f30ad0241c362f66db1790e06da6f9ddf4550c%2Ffnos-mysql-success.png?alt=media)

当server容器日志中出现如下内容表示后台成功\
![](https://2091425001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FawfuokzR4YAbJkI2zXf0%2Fuploads%2Fgit-blob-ee7ee19fc6c28228d89b8714a9d68cf99ca1c6b8%2Ffnos-server-success.png?alt=media)
