搭建自己的私有云盘系统(owncloud)

搭建自己的私有云盘系统(owncloud)

  • 一:准备工作
    • 1.1:安装docker
    • 1.2:修改或者添加国内镜像源
    • 1.3:重启docker服务使配置生效
    • 1.4:安装docker-compose
  • 二:开始安装owncloud
    • 2.1:创建owncloud启动目录
    • 2.2:创建启动yml文件
    • 2.3:创建环境配置文件
    • 2.4:构建并启动容器
  • 三:检查owncloud是否正常启动
  • 四:访问网盘

这里使用docker-compose安装,简单且容易维护,LAMP搭建复杂且容易出各种问题,搭建不易

一:准备工作

1.1:安装docker

apt install docker.io

1.2:修改或者添加国内镜像源

# 创建或修改 /etc/docker/daemon.json 文件,修改为如下形式
#vim /etc/docker/daemon.json
{
    "registry-mirrors" : [
    "https://registry.docker-cn.com",
    "https://docker.mirrors.ustc.edu.cn",
    "http://hub-mirror.c.163.com",
    "https://cr.console.aliyun.com/"
  ]
}

1.3:重启docker服务使配置生效

systemctl restart docker.service

1.4:安装docker-compose

apt install docker-compose

二:开始安装owncloud

2.1:创建owncloud启动目录

mkdir owncloud-docker-server
cd owncloud-docker-server

2.2:创建启动yml文件

wget https://raw.githubusercontent.com/owncloud/docs/master/modules/admin_manual/examples/installation/docker/docker-compose.yml

有的朋友无法访问上面的连接这里提供了yaml配置,如下所示:

#vim docker-compose.yml
version: '2.1'

volumes:
  files:
    driver: local
  mysql:
    driver: local
  backup:
    driver: local
  redis:
    driver: local

services:
  owncloud:
    image: owncloud/server:${OWNCLOUD_VERSION}
    restart: always
    ports:
      - ${HTTP_PORT}:8080
    depends_on:
      - db
      - redis
    environment:
      - OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=owncloud
      - OWNCLOUD_DB_HOST=db
      - OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
      - OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - OWNCLOUD_MYSQL_UTF8MB4=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - files:/mnt/data

  db:
    image: webhippie/mariadb:latest
    restart: always
    environment:
      - MARIADB_ROOT_PASSWORD=owncloud
      - MARIADB_USERNAME=owncloud
      - MARIADB_PASSWORD=owncloud
      - MARIADB_DATABASE=owncloud
      - MARIADB_MAX_ALLOWED_PACKET=128M
      - MARIADB_INNODB_LOG_FILE_SIZE=64M
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - mysql:/var/lib/mysql
      - backup:/var/lib/backup

  redis:
    image: webhippie/redis:latest
    restart: always
    environment:
      - REDIS_DATABASES=1
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - redis:/var/lib/redis

2.3:创建环境配置文件

cat << EOF > .env
OWNCLOUD_VERSION=10.5
OWNCLOUD_DOMAIN=localhost
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin
HTTP_PORT=8080
EOF

2.4:构建并启动容器

docker-compose up -d

三:检查owncloud是否正常启动

docker-compose ps

如下所示结果,即为成功启动

Name                              Command                     State   Ports
__________________________________________________________________________________________
ownclouddockerserver_db_1         … /bin/s6-svscan /etc/s6    Up      3306/tcp
ownclouddockerserver_owncloud_1   … /usr/bin/owncloud server  Up      0.0.0.0:8080->8080/tcp
ownclouddockerserver_redis_1      … /bin/s6-svscan /etc/s6    Up      6379/tcp

四:访问网盘

浏览器访问http://IP:8080 账号和密码在.env 文件中配置了即admin admin
搭建自己的私有云盘系统(owncloud)_第1张图片
查看数据本地存储位置

docker volume ls

查看详情

DRIVER              VOLUME NAME
local               owncloud-docker-server_backup
local               owncloud-docker-server_files
local               owncloud-docker-server_mysql
local               owncloud-docker-server_redis
docker volume inspect owncloud-docker-server_files

可以看到/var/lib/docker/volumes/owncloud-docker-server_files/_data就是owncloud本地数据存放的位置

[
    {
        "CreatedAt": "2020-08-24T22:45:17+08:00",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "owncloud-docker-server",
            "com.docker.compose.version": "1.25.0",
            "com.docker.compose.volume": "files"
        },
        "Mountpoint": "/var/lib/docker/volumes/owncloud-docker-server_files/_data",
        "Name": "owncloud-docker-server_files",
        "Options": null,
        "Scope": "local"
    }
]

你可能感兴趣的:(搭建自己的私有云盘系统(owncloud))