这个文章只是简单记录一下部署过程,不会讲的太细。
开启网络共享协议
其实就是安装一下 Samba
这个软件。安装步骤如下:
sudo apt-get install samba samba-common-bin
# 安装
sudo nano /etc/samba/smb.conf
#修改配置文件
# 在smb.conf文件末尾加入下边两段
[myshare] # 显示名称
comment = my share directory # 共享说明
path = /home/pi # 共享目录,可自行修改
browseable = yes # 可读权限
writeable = yes # 写入权限
guest ok = yes # 可写可不写
[portable] # 移动硬盘
comment = portable disk
path = /media/pi # 移动硬盘目录,接几个都会显示在这里
browseable = yes
writeable = yes
guest ok = yes
# 保存(ctrl+o)退出(ctrl+x)
sudo smbpasswd -a pi
# 默认用户pi,设置密码
sudo service smbd restart
# 重启服务
这里注意配置文件每行后面不能有空格,还有记得给文件777的权限,要不然无法写
效果如下
详细可以参考
树莓派4B踩坑指南 - (13)用samba建立家庭局域网共享中心 - Bowen404 - 博客园 (cnblogs.com)
如果启动失败
因为我们直接用网线,所以我们需要禁用wifi。我们使用rfkill来卸载
sudo apt install rfkill
sudo rfkill block wifi
# 禁用蓝牙
sudo rfkill block bluetooth
# 恢复wifi
sudo rfkill unblock wifi
然后又报错。。还需要关闭防火墙
# 查看防火墙状态
sudo ufw status
# 关闭防火墙
sudo ufw disable
注意,现在很多电视可能会无法访问,我们需要支持smb1.0才行
client min protocol = NT1
server min protocol = NT1
挂载硬盘
莓派空间太小了,所以我单独买了一块4T的机械硬盘,下面我们来进行操作
首先我们查找硬盘 sudo fdisk -l
发现在/dev/sda1上
下面我们进行挂载,我们创建一个文件夹,然后再挂载
mkdir /mnt/sda1
chmod 777 /mnt/sda1
sudo mount /dev/sda1 /mnt/sda1
我们查看一下硬盘挂载情况 df -T
可以看到,硬盘已经挂载上去了。(注意硬盘需要格式化,我用的ubuntu系统,支持ntfs格式,所以windows和树莓派都可以访问)
然后我们可以修改一下samba的配置,把里面的路径改成自己的路径就可以了(记得重启服务)
尝试移动文件,大概在28m/s左右。。速度还是不错的。(我用固态试了一下可以达到60m/s的速度)
搭建下载器
这个其实我很早就出过教程了,现在我们在树莓派上安装一下~
安装命令如下
sudo apt-get install aria2
# 新建配置文件
mkdir -p ~/.config/aria2/
touch ~/.config/aria2/aria2.session
vim ~/.config/aria2/aria2.config
# 里面加上这些内容
# set your own path
dir=[yourpath]
disk-cache=32M
file-allocation=trunc
continue=true
max-concurrent-downloads=10
max-connection-per-server=16
min-split-size=10M
split=5
max-overall-download-limit=0
#max-download-limit=0
#max-overall-upload-limit=0
#max-upload-limit=0
disable-ipv6=false
save-session=~/.config/aria2/aria2.session
input-file=~/.config/aria2/aria2.session
save-session-interval=60
enable-rpc=true
rpc-allow-origin-all=true
rpc-listen-all=true
#rpc-secret=secret
#event-poll=select
#rpc-listen-port=6800
# for PT user please set to false
enable-dht=true
enable-dht6=true
enable-peer-exchange=true
# for increasing BT speed
listen-port=51413
#follow-torrent=true
#bt-max-peers=55
#dht-listen-port=6881-6999
#bt-enable-lpd=false
#bt-request-peer-speed-limit=50K
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
seed-ratio=0
#force-save=false
#bt-hash-check-seed=true
bt-seed-unverified=true
bt-save-metadata=true
bt-tracker=udp://62.138.0.158:6969/announce,udp://87.233.192.220:6969/announce,udp://111.6.78.96:6969/announce,udp://90.179.64.91:1337/announce,udp://51.15.4.13:1337/announce,udp://151.80.120.113:2710/announce,udp://191.96.249.23:6969/announce,udp://35.187.36.248:1337/announce,udp://123.249.16.65:2710/announce,udp://210.244.71.25:6969/announce,udp://78.142.19.42:1337/announce,udp://173.254.219.72:6969/announce,udp://51.15.76.199:6969/announce,udp://51.15.40.114:80/announce,udp://91.212.150.191:3418/announce,udp://103.224.212.222:6969/announce,udp://5.79.83.194:6969/announce,udp://92.241.171.245:6969/announce,udp://5.79.209.57:6969/announce,udp://82.118.242.198:1337/announce
下面这个是密码
我们测试一下 ,我这为了方便,直接用的绝对路径 aria2c --conf-path=/home/ubuntu/.config/aria2/aria2.config
如果报文件路径没有找到,那么就把里面的~改成绝对路径
如果想后台启动,那么就加上-D
配置web UI界面
直接从github下载,这个是html文件,自己创建一个网址,把代码丢进去
Releases · mayswind/AriaNg (github.com)
然后我们就可以下载东西了~~
搭建视频播放器
除了下载东西,我们还需要播放视频,这里我还是选择之前已经下载过的plex,这个安装也不难,参考下面这个:我们直接到官网下载安装包就行
Media Server Downloads | Plex Media Server for Windows, Mac, Linux, FreeBSD and More
树莓派是这个
然后我们安装一下,自己记得修改自己的文件名字
sudo dpkg -i plexmediaserver_1.23.3.4707-ebb5fe9f3_arm64.deb
然后我们启动服务(注意这个端口是32400)
sudo systemctl enable plexmediaserver.service
sudo systemctl start plexmediaserver.service
访问的时候使用 http://ip:32400/web
才能访问,可以看到已经可以访问了!
这东西其实可玩性很高,这里我就不展开讲了。。
不过这玩意需要实时转码,非常耗树莓派性能,看电影非常卡。。
所以我情愿用smb协议来看。。。
相册搭建
找到一个还算可以的
photoprism/photoprism: Open-Source Photo Management powered by Go and Google TensorFlow (github.com)
参考这个:(6条消息) PhotoPrism 入门教程:如何搭建私有相册系统_Xpitz的博客-CSDN博客_photoprism
首先确保自己安装了docker,这个我就不管了,自己安装。安装方法如下
sudo apt install docker-compose
# 自己新建一个yml文件
vim docker-compose.yml
本来这个是从网上下载的,但是那个要用两个镜像,我觉得没必要,所以直接贴配置了(这里需要自己新建数据库,数据库名和密码都是photoprism)
version: '3.5'
# Example Docker Compose config file for PhotoPrism (Raspberry Pi / ARM64)
#
# Documentation : https://docs.photoprism.org/getting-started/raspberry-pi/
# Docker Hub URL: https://hub.docker.com/r/photoprism/photoprism-arm64/
#
# Please run behind a reverse proxy like Caddy, Traefik or Nginx if you need HTTPS / SSL support
# e.g. when running PhotoPrism on a public server outside your home network.
#
# -------------------------------------------------------------------
# DOCKER COMPOSE COMMAND REFERENCE
# -------------------------------------------------------------------
# Start | docker-compose up -d
# Stop | docker-compose stop
# Update | docker-compose pull
# Logs | docker-compose logs --tail=25 -f
# Terminal | docker-compose exec photoprism bash
# Help | docker-compose exec photoprism photoprism help
# Config | docker-compose exec photoprism photoprism config
# Reset | docker-compose exec photoprism photoprism reset
# Backup | docker-compose exec photoprism photoprism backup -a -i
# Restore | docker-compose exec photoprism photoprism restore -a -i
# Index | docker-compose exec photoprism photoprism index
# Reindex | docker-compose exec photoprism photoprism index -a
# Import | docker-compose exec photoprism photoprism import
# -------------------------------------------------------------------
# Note: All commands may have to be prefixed with "sudo" when not running as root.
# This will change the home directory "~" to "/root" in your configuration.
services:
photoprism:
# Use photoprism/photoprism-arm64:preview instead for testing preview builds:
image: photoprism/photoprism-arm64:latest
container_name: photoprism
# Only enable automatic restarts once your installation is properly
# configured as it otherwise may get stuck in a restart loop:
# https://docs.photoprism.org/getting-started/faq/#why-is-photoprism-getting-stuck-in-a-restart-loop
# restart: unless-stopped
security_opt:
- seccomp:unconfined
- apparmor:unconfined
# ports:
# - 2342:2342 # [local port]:[container port]
network_mode: "host"
environment:
PHOTOPRISM_ADMIN_PASSWORD: "insecure" # PLEASE CHANGE: Your initial admin password (min 4 characters)
PHOTOPRISM_ORIGINALS_LIMIT: 1000 # File size limit for originals in MB (increase for high-res video)
PHOTOPRISM_HTTP_COMPRESSION: "none" # Improves transfer speed and bandwidth utilization (none or gzip)
PHOTOPRISM_WORKERS: 2 # Limits the number of indexing workers to reduce system load
PHOTOPRISM_DEBUG: "false" # Run in debug mode (shows additional log messages)
PHOTOPRISM_PUBLIC: "false" # No authentication required (disables password protection)
PHOTOPRISM_READONLY: "false" # Don't modify originals directory (reduced functionality)
PHOTOPRISM_EXPERIMENTAL: "false" # Enables experimental features
PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server
PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI
PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Disables using TensorFlow for image classification
PHOTOPRISM_DARKTABLE_PRESETS: "true" # Enables Darktable presets and disables concurrent RAW conversion
# PHOTOPRISM_FFMPEG_ENCODER: "h264_v4l2m2m" # FFmpeg AVC encoder for video transcoding (default: libx264)
# PHOTOPRISM_FFMPEG_BUFFERS: "64" # FFmpeg capture buffers (default: 32)
PHOTOPRISM_DETECT_NSFW: "false" # Flag photos as private that MAY be offensive
PHOTOPRISM_UPLOAD_NSFW: "true" # Allow uploads that MAY be offensive
# PHOTOPRISM_DATABASE_DRIVER: "sqlite" # SQLite is an embedded database that doesn't require a server
PHOTOPRISM_DATABASE_DRIVER: "mysql" # Use MariaDB (or MySQL) instead of SQLite for improved performance
PHOTOPRISM_DATABASE_SERVER: "localhost:3306" # MariaDB database server (hostname:port)
PHOTOPRISM_DATABASE_NAME: "photoprism" # MariaDB database schema name
PHOTOPRISM_DATABASE_USER: "photoprism" # MariaDB database user name
PHOTOPRISM_DATABASE_PASSWORD: "photoprism" # MariaDB database user password
PHOTOPRISM_SITE_URL: "http://localhost:2342/" # Public PhotoPrism URL
PHOTOPRISM_SITE_TITLE: "PhotoPrism"
PHOTOPRISM_SITE_CAPTION: "Browse Your Life"
PHOTOPRISM_SITE_DESCRIPTION: ""
PHOTOPRISM_SITE_AUTHOR: ""
# You may optionally set a user / group id using environment variables if your Docker version or NAS does not
# support this natively (see next example):
# UID: 1000
# GID: 1000
# UMASK: 0000
# Uncomment and edit the following line to set a specific user / group id (native):
# user: "1000:1000"
# For hardware AVC transcoding using the h264_v4l2m2m encoder:
# devices:
# - "/dev/video11:/dev/video11"
volumes:
# Your photo and video files ([local path]:[container path]):
- "/xiaoyou/sd1/photo:/photoprism/originals"
# Multiple folders can be indexed by mounting them as sub-folders of /photoprism/originals:
# - "/mnt/Family:/photoprism/originals/Family" # [folder_1]:/photoprism/originals/[folder_1]
# - "/mnt/Friends:/photoprism/originals/Friends" # [folder_2]:/photoprism/originals/[folder_2]
# Mounting an import folder is optional (see docs):
# - "~/Import:/photoprism/import"
# Permanent storage for settings, index & sidecar files (DON'T REMOVE):
- "./storage:/photoprism/storage"
# Uncomment the following lines to upgrade automatically, whenever there is a new Docker image available:
#
# watchtower:
# image: containrrr/watchtower
# container_name: watchtower
# restart: unless-stopped
# environment:
# WATCHTOWER_CLEANUP: "true"
# WATCHTOWER_POLL_INTERVAL: 7200 # Checks for updates every two hours
# volumes:
# - "/var/run/docker.sock:/var/run/docker.sock"
# - "~/.docker/config.json:/config.json" # Optional, for authentication if you have a Docker Hub account
备注:docker设置代理:Control Docker with systemd | Docker Documentation
自己访问 http://ip:2342
就可以访问了,密码用的是默认的 insecure
出现下面这个画面说明安装成功
我们上传几张照片,可以看到效果还是不错的
音乐播放器搭建
本来想安装 koel/koel: 🐦 A personal music streaming server that works. (github.com) 的,但是这个东西安装太麻烦了,我实在不想用这个了,换一个。。。
我们换一个吧。。。
Subsonic 直接下载adb包就可以了
下面是一些常用命令
# 开机启动
sudo systemctl enable subsonic
# 启动
sudo systemctl start subsonic
# 查看状态
systemctl status subsonic
出现下面这个错误说明我们安装的是java11,我们要用java8
可以使用 sudo update-alternatives --config java
来切换java版本
输入 http://ip:4040 就可以进入系统了
备注:npm设置和取消代理的方法_yanzi1225627的专栏-CSDN博客_npm 设置代理
书库搭建
talebook/talebook: A simple books website. 一个简单的在线版个人书库。 (github.com)
这个直接用docker运行就可以了~~不过这东西没有arm版的。感觉这个也一般般,所以先不管
我们用老板的
# 安装依赖
pip3 install --target vendor -r requirements.txt
# 启动项目
python3 cps.py
关于怎么添加书籍我这里就不说了
git搭建
可以搭建一个git仓库,放一些私有代码,这里我们不用gitlab,因为这个东西比较占用空间,所以giteaGitea
在这里下载gitea | Gitea 选择arm64
安装参考这个:
然后访问: http://ip:3000
就可以访问了
这个东西配合迁移功能可以把github上的代码迁移到本地,我们可以本地保存起来。。
进程管理参考这个:
Supervisor使用详解 - 简书 (jianshu.com)
迅雷下载固件
首先我们需要下载固件 yysolid/Xware: Xware1.0.31 (github.com)
下载
这个不知道咋回事,一直无法启动,想搭建的参考下面这个文章,我感觉不需要了。。。
树莓派配合迅雷搭建远程下载机_树莓派爱好者基地的博客-CSDN博客
树莓派监控
我们使用netData来监控我们的树莓派,官方github:
可能要配置代理服务器才能下载。。。。
bash <(curl -Ss https://my-netdata.io/kickstart.sh)
安装好后我们访问 http://ip:19999
就可以看到效果了
DNS服务器
我们安装这个来进行广告过滤,安装过程非常简单,直接运行下面这个命令(我后面用的docker部署)
curl -sSL https://install.pi-hole.net | bash
官方地址:https://pi-hole.net/
关于端口占用问题参考:
dnsmasq: failed to create listening socket for port 53: Address already in use - Ask Ubuntu
pi-hole/docker-pi-hole: Pi-hole in a docker container (github.com)
密码在这里
重设密码参考:pi-hole/docker-pi-hole: Pi-hole in a docker container (github.com)
界面如下
搭建Minecraft服务器
我们下载服务jar包,如果自己是其他版本的只需要自己修改一下顶部的url的版本就可以了
MCVersions.net - Create your own 1.14.1 Minecraft server!
然后使用下面这个命令来启动,注意自己的版本
java -Xmx1024M -Xms1024M -jar minecraft_server.1.17.1.jar
下面这里记得改成true
不改的话会报错
可以参考这个:树莓派搭建Minecraft服务器全攻略 - 简书 (jianshu.com)
不止不觉搞了快两天了,目前先只搞这些,后面有时间再搞其他的。。。