人们不是嘲笑你的梦想
他们嘲笑的是你的实力

photoprism:一个照片管理程序

前言

photoprism是一个开源的照片管理程序,他不像图床那种是用来分享照片的

当你不想把照片放到云盘等可能泄漏隐私的地方,或者是觉得单纯放在移动设备里可能会丢失

并且你是摄影师、拍照达人等,对管理照片有较高要求,那么它会很适合你

github:https://link.zhihu.com/?target=https%3A//github.com/photoprism/photoprism/
官网:https://link.zhihu.com/?target=https%3A//docs.photoprism.org/

安装环境

官网推荐的最低配置是2c4g,我们这里以debian11为例

photoprism开发之初就是为docker而设计的

所以我们也采用官网推荐的docker形式安装

docker

apt-get update
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   stable"
apt-get update -y
apt-get install docker-ce docker-ce-cli containerd.io
systemctl enable --now docker

docker-compose

curl -L https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-`uname -m` > ./docker-compose
chmod +x ./docker-compose
mv ./docker-compose /usr/local/bin/docker-compos

nginx

apt-get install -y nginx
systemctl enable --now nginx

安装

我们新建一个compose

nano docker-compose.yml

写入以下配置

version: '3.5'

services:
  photoprism:
    # 使用 photoprism/photoprism:preview 来尝试抢先版
    image: photoprism/photoprism:latest
    container_name: photoprism
    # 设置重启策略
    restart: unless-stopped
    security_opt:
      - seccomp:unconfined
      - apparmor:unconfined
    ports:
      - 2342:2342
    environment:
      PHOTOPRISM_ADMIN_PASSWORD: "photoprism"        # 设置管理员密码,至少包含四个字符
      PHOTOPRISM_HTTP_PORT: 2342                     # 内部监听端口
      PHOTOPRISM_HTTP_COMPRESSION: "gzip"            # 是否开启文件压缩,开启可以提升文件传输速度 (选项:none or gzip)
      PHOTOPRISM_DEBUG: "false"                      # 是否开启 debug 模式
      PHOTOPRISM_PUBLIC: "false"                     # 认证开关
      PHOTOPRISM_READONLY: "false"                   # 只读开关
      PHOTOPRISM_EXPERIMENTAL: "false"               # 是否开启实验特性
      PHOTOPRISM_DISABLE_WEBDAV: "false"             # 是否禁用 WebDAV 服务
      PHOTOPRISM_DISABLE_SETTINGS: "false"           # 是否禁用页面设置
      PHOTOPRISM_DISABLE_TENSORFLOW: "false"         # 是否禁用 TensorFlow 进行图片分类
      PHOTOPRISM_DARKTABLE_PRESETS: "false"          
      PHOTOPRISM_DETECT_NSFW: "false"                # 是否将令人感到不适的照片标记为私有
      PHOTOPRISM_UPLOAD_NSFW: "true"                 # 是否允许上传可能让人感到不适的文件
      # PHOTOPRISM_DATABASE_DRIVER: "sqlite"         # 使用 SQLite 作为数据库,已内置无需创建实例
      PHOTOPRISM_DATABASE_DRIVER: "mysql"            # 使用 MariaDB (或 MySQL) 代替 SQLite 来提升性能
      PHOTOPRISM_DATABASE_SERVER: "mariadb:3306"     # 设置 MariaDB 服务 (hostname:port)
      PHOTOPRISM_DATABASE_NAME: "photoprism"         # 设置 MariaDB 库名
      PHOTOPRISM_DATABASE_USER: "photoprism"         # 指定 MariaDB 的用户
      PHOTOPRISM_DATABASE_PASSWORD: "photoprism"     # 设置 MariaDB 用户密码
      PHOTOPRISM_SITE_URL: "http://localhost:2342/"  # PhotoPrism 访问地址
      PHOTOPRISM_SITE_TITLE: "PhotoPrism"
      PHOTOPRISM_SITE_CAPTION: "Browse Your Life"
      PHOTOPRISM_SITE_DESCRIPTION: ""
      PHOTOPRISM_SITE_AUTHOR: ""
      # 如果 docker 或 NAS 未设置用户,可以添加环境变量来设置,示例如下:
      # UID: 1000
      # GID: 1000
      # UMASK: 0000
    # 取消注释来指定用户
    # user: "1000:1000"
    volumes:
      # 图片与视频的原生目录,文件上传后先存放在这里
      - "~/Pictures:/photoprism/originals"
      # 原生目录下的子目录,按照实际需求来挂载
      # - "/mnt/Family:/photoprism/originals/Family"    # [folder_1]:/photoprism/originals/[folder_1]
      # - "/mnt/Friends:/photoprism/originals/Friends"  # [folder_2]:/photoprism/originals/[folder_2]
      # 挂在导入目录,如果该目录中存在文件会自动导入
      # - "~/Import:/photoprism/import"
      # 缓存目录 (请勿删除):
      - "./storage:/photoprism/storage"

  mariadb:
    image: mariadb:10.5
    container_name: mariadb
    restart: unless-stopped
    security_opt:
      - seccomp:unconfined
      - apparmor:unconfined
    command: mysqld --transaction-isolation=READ-COMMITTED --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=512 --innodb-rollback-on-timeout=OFF --innodb-lock-wait-timeout=50
    volumes:
      - "./database:/var/lib/mysql"
    environment:
      MYSQL_ROOT_PASSWORD: photoprism
      MYSQL_DATABASE: photoprism
      MYSQL_USER: photoprism
      MYSQL_PASSWORD: photoprism

# 如果需要自动更新镜像,可以取消这段注释
#
#  watchtower:
#    image: containrrr/watchtower
#    restart: unless-stopped
#    environment:
#      WATCHTOWER_CLEANUP: "true"
#      WATCHTOWER_POLL_INTERVAL: 7200
#    volumes:
#      - "/var/run/docker.sock:/var/run/docker.sock"

这几个配置项要自己改一下

PHOTOPRISM_ADMIN_PASSWORD
PHOTOPRISM_DATABASE_PASSWORD
PHOTOPRISM_SITE_URL
MYSQL_ROOT_PASSWORD
MYSQL_PASSWORD

然后我们启动即可

docker-compose up -d

公网访问

我们用nginx配置反向代理

新建站点配置文件

nano /etc/nginx/conf.d/photoprism.conf

写入下列配置

server {
    listen 80;
    server_name photoprism.baidu.com;
    client_max_body_size 0;

    location / {
        proxy_pass http://127.0.0.1:2342;
       	proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
       	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

更新版本

当有新版本要更新的时候可以执行

docker-compose pull photoprism
docker-compose stop photoprism
docker-compose up -d photoprism

也可以把配置文件最后那段的注释去掉,他就自己更新了

最后

打开页面就是这样

记得在设置里改为中文并且开启删除选项

未经允许不得转载:四四的军火库 » photoprism:一个照片管理程序