一、初始化配置

1. 更换国内源

(使用的是 Debian 源)https://mirrors.tuna.tsinghua.edu.cn/help/debian/

  1. mv /etc/apt/sources.list /etc/apt/sources.list.bak
  2. vi /etc/apt/sources.list
  1. # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
  2. deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free
  3. # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free
  4. deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free
  5. # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free
  6. deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free
  7. # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free
  8. deb https://mirrors.tuna.tsinghua.edu.cn/debian-security stretch/updates main contrib non-free
  9. # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security stretch/updates main contrib non-free
  1. apt update -y && apt upgrade -y

2. 安装中文字体,修改系统语言

  1. apt install -y ttf-wqy-microhei ttf-wqy-zenhei
  1. armbian-config

personal —> Locales 进入语言选择界面,勾选:

  1. [ * ] en_US.UTF-8 UTF-8
  2. [ * ] zh_CN.GBK GBK
  3. [ * ] zh_CN.UTF-8 UTF-8

选择 OK,进入下一界面,选择 en_US.UTF-8 UTF-8

3.挂载外置存储

  • 开机自动挂载 NTFS 分区
    安装 ntfs-3g
    查看挂载点
    新建一个目录,然后修改 /etc/fstab
    添加如下内容(比如挂载 /dev/sda3)
    1. apt install -y ntfs-3g
    1. fdisk -l
    1. Device Start End Sectors Size Type
    2. /dev/sda1 34 32767 32734 16M Microsoft reserved
    3. /dev/sda2 32768 268468223 268435456 128G Microsoft basic data
    4. /dev/sda3 268468224 1953521663 1685053440 803.5G Microsoft basic data
    1. mkdir /mnt/disk_name
    2. vi /etc/fstab
    1. /dev/sda3 /mnt/phidata ntfs-3g defaults 0 0

二、搭建 NAS

1. 云盘功能

1.1 NextCloud

  1. apt install -y snapd
  2. snap install nextcloud

访问 http://your_server_ip 按提示配置

Tips: 修改数据存储文件夹的方法 修改 /var/snap/nextcloud/current/nextcloud/config/config.phpdatadirectory 的值为 /dest/nextcloud/data,然后重启 nextcloud

  1. cp -a /var/snap/nextcloud/common/nextcloud/data/ /dest/nextcloud
  1. snap restart nextcloud

Tips: 你的数据目录可被其他用户读取 请更改权限为 0770 以避免其他用户查看目录. 的解决办法 修改 /etc/fstab 修改 util.php(改法可能行不通,因为没有 util.php 的写权限) 将 checkDataDirectoryPermissions 修改为

  1. /dev/sda3 /mnt/phidata ntfs-3g defaults,permissions 0 0
  1. chmod -R 770 /dest/nextcloud/data
  1. vi /snap/nextcloud/10318/htdocs/lib/private/legacy/util.php
  1. public static function checkDataDirectoryPermissions($dataDirectory) {
  2. if(\OC::$server->getConfig()->getSystemValue('check_data_directory_permissions', true) === false) {
  3. return [];
  4. }
  5. $l = \OC::$server->getL10N('lib');
  6. $errors = [];
  7. // $permissionsModHint = $l->t('Please change the permissions to 0770 so that the directory'
  8. // . ' cannot be listed by other users.');
  9. // $perms = substr(decoct(@fileperms($dataDirectory)), -3);
  10. // if (substr($perms, -1) !== '0') {
  11. // chmod($dataDirectory, 0770);
  12. // clearstatcache();
  13. // $perms = substr(decoct(@fileperms($dataDirectory)), -3);
  14. // if ($perms[2] !== '0') {
  15. // $errors[] = [
  16. // 'error' => $l->t('Your data directory is readable by other users'),
  17. // 'hint' => $permissionsModHint
  18. // ];
  19. // }
  20. // }
  21. return $errors;
  22. }

1.2 Filebrowser

  1. curl -fsSL https://filebrowser.github.io/get.sh | bash

编辑 /home/filebrowser/config.json

  1. {
  2. "port": 8000,
  3. "database": "/home/filebrowser/database.db",
  4. "scope": "/mnt/phidata",
  5. "allowCommands": true,
  6. "allowEdit": true,
  7. "allowNew": true,
  8. "commands": [
  9. "wget"
  10. ]
  11. }
  1. filebrowser -c /home/filebrowser/config.json

访问 http://your_server_ip:8000 按提示配置

加入开机启动

1. 影音功能

2.1 Emby

下载页面 https://emby.media/linux-server.html

  1. wget https://github.com/MediaBrowser/Emby.Releases/releases/download/3.6.0.82/emby-server-deb_3.6.0.82_arm64.deb
  2. dpkg -i emby-server-deb_3.6.0.82_arm64.deb

访问 http://your_server_ip:8096 按提示配置

2.2 Plex Media Server

参考这里 https://dev2day.de/plex-media-server-arm/

  1. # root 下执行
  2. # add public key
  3. wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | apt-key add -
  4. # add PMS repo
  5. echo "deb [arch=armhf] https://dev2day.de/pms/ stretch main" >> /etc/apt/sources.list.d/pms.list
  6. # activate https
  7. apt install apt-transport-https
  8. # enable armhf support
  9. dpkg --add-architecture armhf
  10. # update the repos
  11. apt update
  12. # install PMS
  13. apt install plexmediaserver-installer:armhf

访问 http://your_server_ip:32400/web 按提示配置

3.下载功能

3.1 Aria2

  1. apt install -y aria2
  2. mkdir /etc/aria2
  3. touch /etc/aria2/aria2.session
  4. touch /etc/aria2/aria2.conf

编辑 /etc/aria2/aria2.conf

  1. ## RPC相关设置 ##
  2. # 启用RPC, 默认:false
  3. enable-rpc=true
  4. # 允许所有来源, 默认:false
  5. rpc-allow-origin-all=true
  6. # 允许外部访问, 默认:false
  7. rpc-listen-all=true
  8. # RPC端口, 仅当默认端口被占用时修改
  9. #rpc-listen-port=6800
  10. # 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项
  11. #rpc-secret=yourpasswordhere
  12. ## 文件保存相关 ##
  13. # 文件保存目录
  14. dir=/mnt/phidata/download
  15. # 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M
  16. disk-cache=32M
  17. # 断点续传
  18. continue=true
  19. # 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc
  20. # 预分配所需时间: none < falloc ? trunc < prealloc
  21. # falloc和trunc则需要文件系统和内核支持
  22. # NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项
  23. #file-allocation=falloc
  24. ## 下载连接相关 ##
  25. # 最大同时下载任务数, 运行时可修改, 默认:5
  26. max-concurrent-downloads=2
  27. # 同一服务器连接数, 添加时可指定, 默认:1
  28. max-connection-per-server=5
  29. # 整体下载速度限制, 运行时可修改, 默认:0(不限制)
  30. #max-overall-download-limit=0
  31. # 单个任务下载速度限制, 默认:0(不限制)
  32. #max-download-limit=0
  33. # 整体上传速度限制, 运行时可修改, 默认:0(不限制)
  34. #max-overall-upload-limit=0
  35. # 单个任务上传速度限制, 默认:0(不限制)
  36. #max-upload-limit=0
  37. # 禁用IPv6, 默认:false
  38. disable-ipv6=true
  39. # 最小文件分片大小, 添加时可指定, 取值范围 1M -1024M , 默认:20M
  40. # 假定 size=10M , 文件为 20MiB 则使用两个来源下载; 文件为 15MiB 则使用一个来源下载
  41. min-split-size=10M
  42. # 单个任务最大线程数, 添加时可指定, 默认:5
  43. #split=10
  44. ## 进度保存相关 ##
  45. # 从会话文件中读取下载任务
  46. input-file=/etc/aria2/aria2.session
  47. # 在Aria2退出时保存错误的、未完成的下载任务到会话文件
  48. save-session=/etc/aria2/aria2.session
  49. # 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0
  50. save-session-interval=60
  51. ## BT/PT下载相关 ##
  52. # 当下载的是一个种子(以.torrent结尾)时, 自动开始BT任务, 默认:true
  53. #follow-torrent=true
  54. # 客户端伪装, PT需要
  55. peer-id-prefix=-TR2770-
  56. user-agent=Transmission/2.77
  57. # 强制保存会话, 即使任务已经完成, 默认:false
  58. # 较新的版本开启后会在任务完成后依然保留.aria2文件
  59. #force-save=false
  60. # 继续之前的BT任务时, 无需再次校验, 默认:false
  61. bt-seed-unverified=true
  62. # 保存磁力链接元数据为种子文件(.torrent文件), 默认:false
  63. bt-save-metadata=true

后台运行 Aria2

  1. nohup aria2c --conf-path=/etc/aria2/aria2.conf &

将 Aria2-WebUI 文档放在 /home/aria2/www ,然后启动 nginx

  1. docker run --name aria2-webui -v /home/aria2/www:/usr/share/nginx/html -p 6801:80 -d nginx

Aria2 的 WebUI:

将一下内容加入 /etc/rc.local

  1. docker start 实例ID
  2. nohup aria2c --conf-path=/etc/aria2/aria2.conf &

4.高级功能

4.1 Webmin

4.2 Docker

Docker

4.3 LNMP

4.4 宝塔面板

不支持 arm,不用尝试了!!!


三、其他

1. 计划任务

  • 定时关机
  1. 59 23 * * * /bin/sync && /sbin/poweroff