关于linux:猫盘-群晖-安装-web文件服务器-go-http-file-server

4次阅读

共计 2413 个字符,预计需要花费 7 分钟才能阅读完成。

前言

群晖自带的文件共享曾经很好用了,笼罩了大部份应用场景,然而你敌人手机上可能没有装置 smb 客户端利用。于是就想找一个网页版的文件共享服务器,用来共享些常用工具 app,顺便上传点临时文件,内网应用,不设置账号密码。

下载软件

公布地址 https://github.com/mjpclab/go…

# 查看 cpu 架构
sudo -i
root@DS_cat:~# dpkg --print-architecture
armel
root@DS_cat:~# cat /proc/cpuinfo | grep model
model name  : ARMv8 Processor rev 4 (v8l)
model name  : ARMv8 Processor rev 4 (v8l)

下载地址 https://github.com/mjpclab/go…
解压后失去一个 ghfs 文件

装置配置

# 新建软件目录   把 ghfs 文件传到这个目录
mkdir -p /volume1/opt/ghfs

# 新建服务器的根目录 和 一个用于上传的目录
mkdir -p '/volume1/share/web_file_server/ 长期文件夹(可上传)'

# 创立配置文件
cd /volume1/opt/ghfs
vi ghfs.ini

配置文件内容如下:

--listen-plain 192.168.1.8:8888
--root /volume1/share/web_file_server/
--upload / 长期文件夹(可上传)
--delete / 长期文件夹(可上传)
--hide-dir @eaDir
--access-log /volume1/opt/ghfs/access.log
--error-log /volume1/opt/ghfs/error.log

配置文件部份阐明

  1. @eaDir 是群晖生成的文件夹 设置为不显示
  2. 指定 IP 和端口号 80 端口被群晖占用了
  3. 设置长期文件夹操作权限 可上传 可删除

运行测试

root@DS_cat:/volume1/opt/ghfs# ./ghfs --config ghfs.ini
Host 0 may be accessed by URLs:
   http://192.168.1.8:8888

web_file_server 目录轻易放些 apk jpg 等文件
手机浏览器拜访 192.168.1.8:8888

  • 首页是个文件列表
  • apk 能够下载安装
  • 图片能间接网页浏览 也能下载下来
  • 长期文件夹(可上传) 进入这个文件夹能够上传文件

增加到零碎服务 开机自启

不同零碎的配置可能不太一样 我目前的版本是 DS120j DSM 6.2.4-25556 Update 6

新建服务配置文件 /volume1/opt/ghfs/upstart.conf 内容如下:

#only start this service after the nginx process has started
start on started nginx

#stop the service gracefully if the runlevel changes to 'reboot'
stop on runlevel [06]

#run the scripts as the 'http' user. Running as root (the default) is a bad idea.
#setuid http

#exec the process. Use fully formed path names so that there is no reliance on $PATH
exec /volume1/opt/ghfs/ghfs --config /volume1/opt/ghfs/ghfs.ini
# 增加自启服务配置文件
cp upstart.conf /etc/init/ghfs.conf
# 命令行启动服务测试
root@DS_cat:/volume1/opt/ghfs# start ghfs
ghfs start/running, process 30141
# 进行服务
root@DS_cat:/volume1/opt/ghfs# stop ghfs
ghfs stop/waiting

两头的一些折腾 能够疏忽

默认用 root 账户跑服务 不太安心 改成 http 用户吧

# 批改启动用户为 http
# 去掉 /etc/init/ghfs.conf 文件中  '#setuid http' 后面的 '#'
# 为 http 增加权限
chown http:http -R /volume1/opt/ghfs
chown http:users -R /volume1/share/web_file_server
chmod 750 -R /volume1/share/web_file_server

此时网页拜访可能会呈现 403 禁止拜访资源 目录权限改成 777 也没用 须要到群晖做些权限设置

控制面板 - 用户群组 -http- 编辑 - 权限 在 share 一栏增加 只读权限 最初点确定保留 就能够失常拜访了

刚开始找的几个文件服务器也都能用 然而想暗藏群晖全局搜寻服务生成的 @eaDir 文件夹的话 设置不了或比拟麻烦

  • https://github.com/svenstaro/…
  • https://github.com/codeskyblu…

本想建个软链接来用 发现不行

root@DS_cat:/volume1/opt/ghfs# ln -s upstart.conf /etc/init/ghfs.conf
root@DS_cat:/volume1/opt/ghfs# start ghfs
start: Unknown job: ghfs

一些援用参考

群晖 @eaDir 目录阐明

  • https://zhuanlan.zhihu.com/p/…
  • https://tech.webit.nu/synolog…

开机启动参考

  • https://gist.github.com/SanCo…
  • https://openpeerpower.io/docs…
  • https://segmentfault.com/a/11…
  • https://forum.duplicati.com/t…
正文完
 0