Debian上安装photoview

极空间没有开放docker-compose的权限,想安装PhotoView不行。
换个思路把PhotoView安装到VPS上,把极空间的照片挂载到VPS上,利用VPS做跳板实现相册。

Debian上挂载webdav为本地磁盘

安装davfs

1
apt-get install davfs2

创建挂载目录

1
mkdir /mnt/zero_webdav

挂载webdav

1
mount -t davfs -o noexec http://xxxxxxxxx/xxxxx/photo/ /mnt/zero_webdav/

会提示你输入用户名密码,输入就好了

解除挂载

1
umount /mnt/zero_webdav

安装Docker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
apt-get update
apt-get install ca-certificates curl gnupg
install -m 0755 -d /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg

echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null

apt-get update

apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
apt-get install docker-compose

安装PhotoView

先拉一下镜像:

1
docker pull viktorstrate/photoview

测试安装

创建一个 docker-compose.yml的文件,写入下面的内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
version: "3"

services:
db:
image: mariadb:10.5
restart: always
environment:
- MYSQL_DATABASE=photoview
- MYSQL_USER=photoview
- MYSQL_PASSWORD=photosecret
- MYSQL_RANDOM_ROOT_PASSWORD=1
volumes:
- db_data:/var/lib/mysql

photoview:
image: viktorstrate/photoview:2
restart: always
ports:
- "8000:80"
depends_on:
- db

environment:
- PHOTOVIEW_DATABASE_DRIVER=mysql
- PHOTOVIEW_MYSQL_URL=photoview:photosecret@tcp(db)/photoview
- PHOTOVIEW_LISTEN_IP=photoview
- PHOTOVIEW_LISTEN_PORT=80
- PHOTOVIEW_MEDIA_CACHE=/app/cache

# Optional: If you are using Samba/CIFS-Share and experience problems with "directory not found"
# Enable the following Godebug
# - GODEBUG=asyncpreemptoff=1


# Optional: To enable map related features, you need to create a mapbox token.
# A token can be generated for free here https://account.mapbox.com/access-tokens/
# It's a good idea to limit the scope of the token to your own domain, to prevent others from using it.
# - MAPBOX_TOKEN=<YOUR TOKEN HERE>

volumes:
- api_cache:/app/cache

# Change This: to the directory where your photos are located on your server.
# If the photos are located at `/home/user/photos`, then change this value
# to the following: `/home/user/photos:/photos:ro`.
# You can mount multiple paths, if your photos are spread across multiple directories.
- ./photos_path:/photos:ro

volumes:
db_data:
api_cache:

先什么都不用改,直接测试一下

1
docker-compose up -d

访问 http://xxxxx:8000,成功!

正式安装

先删除原来的container

1
2
3
docker ps #看一下镜像名,会有两个,有一个是DB
docker stop xxx
docker rm xxx

修改docker-compose.yml.

  • 映射端口改回80
  • 照片的路径改为挂载webdav的地址 /mnt/zero_webdav

重新compose