乐橙SN1 ubuntu docker Nextcloud-mysql-redis-nginx yml 部署记录

刷机步骤

1.从build-imou-sn1下载喜欢的linux发现版本,用balenaetcher写盘工具写入U盘(特定U盘才有效(我的是EAGET16G))
2.接上网线,插上U盘USB2.0口后上电启动,
3.通过ssh or TTL 连接登录到alpine恢复系统。
ssh root@imou-sn1
4.在alpine系统中执行emmc-install.sh,写入固件
等灯变为白色即完成。

imou-sn1:~# emmc-install.sh 
flash emmc mbr...
1+0 records in
1+0 records out
512 bytes copied, 0.00471775 s, 109 kB/s
flash emmc ext4 fs...
 848MiB 0:00:39 [21.5MiB/s] [==========================>] 100%            
0+6782 records in
0+6782 records out
889192448 bytes (889 MB, 848 MiB) copied, 62.0352 s, 14.3 MB/s
flash done, please poweroff now then unplug USB drive!

5.写入完成后,根据提示执行poweroff命令关机,断电后拔出U盘,再拔掉电源上电开机,刷机完成。

挂在以及格式化硬盘

因为机器自带硬盘只有4G大小,能力有限,不知道有没有方法可以扩展root目录,只有挂在硬盘只会mount,
1.使用fdisk -l查看目前磁盘情况,根据情况操作对应磁盘。

root@imou-sn1:~# fdisk -l
Disk /dev/mmcblk1: 3.7 GiB, 3959422976 bytes, 7733248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf6a78990

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk1p1       8192 7733247 7725056  3.7G 83 Linux


Disk /dev/sda: 74.54 GiB, 80026361856 bytes, 156301488 sectors
Disk model: Hitachi HTS54328
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

这里我用了一款80G的垃圾盘做测试,可以看到是/dev/sda
2.分区格式化
输入命令fdisk /dev/sda


root@imou-sn1:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

The old ext4 signature will be removed by a write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xc67aca5b.

Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):

Using default response p.
Partition number (1-4, default 1):
First sector (2048-156301487, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-156301487, default 156301487):

Created a new partition 1 of type 'Linux' and of size 74.5 GiB.


Command (m for help):

Command (m for help): w

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

此处磁盘数据没什么用直接全新操作。一顿输入 m n 回车回车回车
最后w保存操作即完成。
接下来格式化为ext4文件系统
mkfs -t ext4 /dev/sda
操作步骤:y 然后一顿回车等待完成即可

root@imou-sn1:~# mkfs -t ext4 /dev/sda
mke2fs 1.45.5 (07-Jan-2020)
Found a dos partition table in /dev/sda
Proceed anyway? (y,N) y
Creating filesystem with 19537686 4k blocks and 4890624 inodes
Filesystem UUID: 3ad32c9e-60a7-4ab6-b54c-ed507cdeb546
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks):
done
Writing superblocks and filesystem accounting information: done

最终查看检查一下ll /dev/sda

root@imou-sn1:~# ll /dev/sda
brw-rw---- 1 root disk 8, 0 Dec  4 22:20 /dev/sda

信息看出来sda为一个块设备文件。8表示主设备号
3.挂在磁盘(因为是内置硬盘,使用永久挂载)
创建一个挂载目录,即空文件夹,我这里使用/www目录
使用永久挂载,就意味着它开机会自动挂载(编辑 /etc/fstab 文件)
命令:blkid:查看对应分区的UUID(编号)。UUID唯一标识每一个分区,防止错误的挂载。除此之外,还会显示分区的类型。(建议先复制一下sdb1的UUID,一会儿会用到)
使用vim编辑 /etc/fstab  在命令行直接输入vim /etc/fstab 就可以编辑,实现开机自动挂载。
因为是新系统,没有安装vim就apt-get install vim -y还是不行无法安装,更新一下apt-get update后,再次运行apt-get install vim -y即可。

# UNCONFIGURED FSTAB FOR BASE SYSTEM
/dev/root / ext4 defaults,noatime,nodiratime,errors=remount-ro 0 1
UUID="3ad32c9e-60a7-4ab6-b54c-ed507cdeb546"  /www ext4 defaults 0 0

重启后lsblk检查即可看到

root@imou-sn1:/www# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda            8:0    1 74.5G  0 disk /www
mmcblk1      179:0    0  3.7G  0 disk
└─mmcblk1p1  179:1    0  3.7G  0 part /
mmcblk1boot0 179:32   0    2M  1 disk
mmcblk1boot1 179:64   0    2M  1 disk

当你的目录被挂载后,该目录下会多出一个目录lost+found。
lost+found:顾名思义,丢失然后找到。它是一个特殊的目录,用来存放文件系统错误导致文件丢失的目录,因此我们的一些数据是可以通过它来找到的。这个目录是在分区的根目录上,就是我们挂载的分区。但这不是每个文件系统都有的目录,ext2/3/4就有这个目录,有些就没有这个目录。

安装docker并修改docker文件路径

# 官方脚本 使用阿里云源
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# 或国内daocloud源
curl -sSL https://get.daocloud.io/docker | sh

安装docker-compose

# 先安装pip
apt install pip -y
# 使用 pip 安装 docker-compose
sudo pip install docker-compose
# 测试是否安装成功
docker-compose --version

修改docker路径

# 查看docker 配置信息
docker info
# 修改docker配置文件路径(没有就新建)
vim /etc/docker/daemon.json 
# 注入路径地址代码
{
  "registry-mirrors": ["http://hub-mirror.c.163.com","https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://9cpn8tt6.mirror.aliyuncs.com"],
  "data-root": "/www/docker"
}
# 重启再次查看是否生效
systemctl restart docker
docker info

配置nextcloud完整docker

配置教程
https://hexo.chensmallx.top/2021/04/08/nextcloud-on-docker/#%E4%BE%9D%E8%B5%96%E5%85%B3%E7%B3%BB

  1. fpm——fastCgi作为呈现层——版本的nextcloud
  2. nginx作为前置反向代理服务器提供https安全
  3. mysql/mariadb作为数据库,提高数据可靠性以及读写性能
  4. redis作为热点数据缓存服务器以及文件锁管理器

依赖关系

  • mariadb(目前mysql都过渡到mariadb了)
  • redis
  • nextcloud:fpm
  • nginx

先安装一个可视化管理面板

https://www.dockernb.com/
docker run --restart always --name fast -p 8081:8081 -d -v /var/run/docker.sock:/var/run/docker.sock wangbinxingkong/fast
但是面板依然不能拉取镜像,不知道是什么问题
用原作者一行代码拉去也无效
一个一个拉取把!

docker pull mariadb
docker pull redis
docker pull nextcloud:fpm
docker pull nginx

其中需要明确一下每个容器在这一套系统中扮演的角色。

nextcloud作为此次的主角,也就是主体业务(app),它在存取数据的时候是会用到数据库(db)和缓存(cache)系统的,那么可以得出nextcloud依赖于mysql和redis。
而mysql和redis之间各司其职,其中一个挂了不会影响到另一个,所以优先级相同,之间没有依赖关系。
nginx作为代理业务和用户之间沟通的主体,首先是需要业务(app)正常运行才能够正常提供它自己本身的服务,所以nginx依赖于nextcloud。

# 依赖关系如下
                     /-> mysql
nginx -> nextcloud -|
                     \-> redis

# 启动顺序则需要反过来
redix&mysql -> nextcloud -> nginx

docker-compose配置文件

docker-compose是一个代理用户去管理docker的一个工具,使用docker-compose.yml配置文件就可以系统、方便地部署多容器项目,因为我们这次搭建的nextcloud也是基于多容器的,所以使用docker-compose进行部署和调试以及重建最为方便。

完整的docker-compose配置参数文档可以参考下面的这个文档,讲的还是比较细致,推荐给要深入docker-compose的同学学习。

Docker Compose 配置文件详解 - 简书

以下就是本文输出的docker-compose配置文件。

注:参数的解释会通过备注的形式写在配置中

yml

version: '3.4'
services:

  db: # 这里只是给每个容器单独配置一个名称
    image: mariadb # 具体的镜像名称,可以使用“:”指定镜像的版本
    restart: unless-stopped # 重启的选项,分为no、on-failure、on-failure:x、always、unless-stopped,具体可以自行搜索查看区别
    expose: 
    # expose仅将指定的端口暴露给links的容器,而不对宿主机开放。
    # 和ports的区别在于,ports可以映射宿主机别的端口到容器中。
     - "3306"
    volumes:
    # volumes指的是将宿主机的路径映射到容器中的指定位置
     - ./db:/var/lib/mysql
    environment:
    # environment可以对容器创建指定多个环境变量
     - MYSQL_ROOT_PASSWORD=root_password # 这里配置root密码
     - MYSQL_DATABASE=nextcloud
     - MYSQL_USER=user_name # 这里配置一个非root账户给nextcloud使用
     - MYSQL_PASSWORD=user_password # 这里配置上面那个账号的密码

  cache:
    image: redis
    restart: unless-stopped
    expose:
     - "6379"
    volumes:
     - ./cache:/data
    command: redis-server --requirepass 'redis_password' # 这里的redis_password换成你要配置的redis密码
    # command指的是启动容器后代替默认启动指令来启动服务的指令

  app:
    image: nextcloud:fpm
    restart: unless-stopped
    expose:
     - "9000"
    volumes:
     - ./app/html:/var/www/html
     - ./app/data:/var/www/html/data
     - ./app/config:/var/www/html/config
     - ./app/custom_apps:/var/www/html/custom_apps
    links:
    # links将容器与当前容器链接起来,以使得当前容器可以访问目标容器expose的端口
    # 格式为 容器的原名:映射到当前容器中的名称
     - db:db
     - cache:cache
    depends_on:
    # 依赖的容器列表,只有这些容器都成功启动了,才会启动当前容器
     - db
     - cache

  proxy: # 叫做proxy是因为是作为代理来提供服务
    image: nginx
    restart: unless-stopped
    expose:
      - "80"
    ports:
    # ports可将容器内的端口映射到宿主机上
    # 这里是将容器的443端口映射到宿主机的7788端口
     - 7788:443
    volumes:
     - ./app/html:/var/www/html
     - ./proxy/conf.d:/etc/nginx/conf.d:ro
     - ./proxy/ssl_certs:/etc/nginx/ssl_certs:ro
    links:
     - app:app
    depends_on:
     - app

把这些内容保存到docker-compose.yml文件中,然后将其放置在某个文件夹中,例如~/super_nextcloud/,我们之后就在这个路径下做后续的操作。

Nginx配置文件

接着我们要准备一下nginx的配置。需要创建两个文件夹,一个是./proxy/conf.d,一个是./proxy/ssl_certs。
其中conf.d放置nginx的配置文件,可以起名叫做nextcloud.conf,ssl_certs放置域名对应的SSL证书的pem和key文件。
mkdir -p ./proxy/conf.d ./proxy/ssl_certs
具体可以参考以下的配置来写nextcloud.conf,其中域名和SSL证书文件的名字需要替换成你自己的。
nginx

upstream php-handler {
    server app:9000;
}

server {
    listen 80;
    listen [::]:80;
    server_name 这里填写自己的域名;
    # enforce https
    return 301 https://$server_name:443$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name 这里填写自己的域名;

    # Use Mozilla's guidelines for SSL/TLS settings
    # https://mozilla.github.io/server-side-tls/ssl-config-generator/
    # NOTE: some settings below might be redundant
    ssl_certificate /etc/nginx/ssl_certs/这里填写SSL证书的名字.pem;
    ssl_certificate_key /etc/nginx/ssl_certs/这里填写SSL证书的名字.key;

    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
    #
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;
    add_header Referrer-Policy no-referrer;
    add_header Strict-Transport-Security  15552000;
    #add_header X-Frame-Options SAMEORIGIN;


    # Remove X-Powered-By, which is an information leak
    fastcgi_hide_header X-Powered-By;

    # Path to the root of your installation
    root /var/www/html;



    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

    # The following rule is only needed for the Social app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/webfinger /public.php?service=webfinger last;

    location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }

    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;

    # Enable gzip but do not remove ETag headers
    gzip on;
    gzip_vary on;
    gzip_comp_level 4;
    gzip_min_length 256;
    gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
    gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;

    location / {
        rewrite ^ /index.php$request_uri;
    }

    location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
        deny all;
    }
    location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }

    location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
        fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        # Avoid sending the security headers twice
        fastcgi_param modHeadersAvailable true;
        # Enable pretty urls
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }

    location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
        try_files $uri/ =404;
        index index.php;
    }

    # Adding the cache control header for js, css and map files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into
        # this topic first.
        #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        add_header Referrer-Policy no-referrer;

        # Optional: Don't log access to assets
        access_log off;
    }

    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
        try_files $uri /index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
    }
}

准备文件中需要证书文件,证书我是freessl申请的,因此需要转换为pem+key,上传到对应位置。


文件都准备好之后,文件结构如下:

super_nextcloud
├── docker-compose.yml
└── proxy
    ├── conf.d
    │   └── nextcloud.conf
    └── ssl_certs
        ├── SSL证书.key
        └── SSL证书.pem

创建&启动容器

此时准备工作已经完成。使用docker-compose代理对docker的容器进行操作可以使用下面的命令:

docker-compose up -d    # 创建所有容器并按顺序启动
docker-compose down     # 停止所有容器并删除
docker-compose stop     # 停止所有容器
docker-compose start    # 按顺序启动所有容器
docker-compose restart  # 停止所有容器并按顺序启动所有容器

所以这里我们使用docker-compose up -d启动我们的服务。在docker-compose输出的提示中,所有目标都显示为done后,我们可以使用netstat查看nginx容器是否在监听7788端口:

❯ netstat -tnlp | grep 7788
tcp6    0     0     :::7788     :::*    LISTEN    5155/docker-proxy

如果没有输出,那就是创建容器有问题。可以通过docker ps -a查看哪些容器在疯狂重启,然后通过docker logs [容器名or容器ID]进到这个容器中查看容器服务日志,自行排障。

如果有输出,并且和上面的内容大致相同,那么恭喜你,构建已经成功大半了。


所有服务都启动起来开始尝试连接nextcloud时发现错误。数据库问题
注册错误提示:nextcloud install Error while trying to initialise the database: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 4047 InnoDB refuses to write tables with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.

解决方法:

这个解决办法有个巨坑,每次重启后都要重新执行一个这个命令。
不然nextcloud就会出现内部错误,技术细节提示。真的很恶心!
但是我也不知道怎么把这个命令写入docker mariadb中。。。。

1.进入mariadb控制台,键入以下命令并回车;
mysql -u root -p
2.输入mariadb的root密码,回车登录;
3.输入以下命令并回车;
SET GLOBAL innodb_read_only_compressed=OFF;
4.这时候再次注册nextcloud,发现成功解决。

配置项目

配置站点

从地址和端口进入站点,通常是https+域名+端口,如果是内网搭建并且不在意域名以及https的小锁头的话,则可以直接通过ip来访问,但是需要注意的是,在nginx中配置了特定域名后,它会检查访问时是否是正确的域名,如果不是正确的域名,那么就会拒绝访问网盘资源。

进入后,我们就需要进行网盘首次配置的一些操作,包括管理员的配置、数据库的配置、应用程序的配置等等。
其中需要注意的是,在数据库配置部分,数据库的地址需要填写我们在docker的links中映射marindb的主机名称,即db;而账号密码则是在配置数据库时制定的数据库用户密码以及数据库名称。

使用上一步配置好的管理员账号和密码登录网盘,点击头像进入设置,现将站点的参数配置好后再配置本账号的参数。

修改Nginx配置

由于在网站上线后,需要配置一系列安全参数,所以需要我们再次去修改一下Nginx的配置文件。

proxy/conf.d/nextcloud.conf中找到这行(也就是上面那个nginx配置的41行),将前面的注释解开,然后重启nginx容器即可(也可以直接使用docker-compose restart重启整个项目)。

nginx


# 如果需要使用手机APP来访问的话,还需要将54 54 59行解开注释

#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

#rewrite ^/.well-known/webfinger /public.php?service=webfinger last;

配置缓存

由于nextcloud默认使用的缓存机制是APCu,我们需要到配置中修改其使用Redis作为缓存。

app/config/config.php中的内容按照如下方法改动:

php

//'memcache.local' => '\\OC\\Memcache\\APCu' // 用本地式缓存使用APCu // 注释这行 
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis', // 分布式缓存使用Redis
'memcache.locking' => '\\OC\\Memcache\\Redis', // 启用Redis缓存的文件锁
'redis' => array(
  'host' => 'cache', // 这里和mariadb的逻辑相同,填写容器links时映射的主机名
  'port' => 6379,
  'password' => 'redis_password' // 这是之前在配置docker-compose时配置的redis密码
),
'filelocking.enabled' => 'true',

使用以下命令进入nextcloud的docker容器,并将文件归属确认改为www-data:

bash

docker exec -it [nextcloud容器的容器ID] /bin/bash
# 进入docker容器之后
ls -l /var/www/html/config/config.php
-rw-r----- 1 www-data www-data 1646 Mar 30 07:27 /var/www/html/config/config.php
# 如果提示所有权不是www-data,那么就要改回www-data
chown www-data:www-data /var/www/html/config/config.php

这时候再去访问nextcloud的页面,就是在使用redis做缓存了。

配置cron定时任务

由于nextcloud内部的文件和配置会在用户操作过程中产生变化,所以需要启用一个定时任务去定期整理和归档这些数据到数据库或者应用到配置中。

先确定自己的nextcloud容器的容器ID或者容器名字,可以使用docker ps -a查看。

然后使用crontab -evim /etc/crontab打开crontab的配置进行编辑,加入如下内容:

plain

# run nextcloud cron task every 5 min
*/5 * * * * docker exec -u 33 [容器ID或容器名] php -f /var/www/html/cron.php 2>&1 /dev/null

建议两个地方都加一次,避免配置不生效。


至此,站点的基本内容已经配置完毕,可以满足个人用于网盘、webdav等使用场景了。

手动安装拓展

nextcloud另一个吸引人的地方就是可以安装很多拓展,但是由于nextcloud是从github上安装拓展,国内的网络连接github又有许许多多的困难,所以直接在页面上点击安装按钮是绝对会报cURL的错的。

所以我想出了一个曲线救国的方法,虽然比直接点击安装要多了几步,但着实可行,实施起来也没有什么阻碍。(反倒是之前为了实现直接点页面安装而各种配置代理浪费了不少时间,而且还有搞不出来…)

手动安装拓展程序的步骤大致可以分为下面几个步骤:

  1. 确保当前客户机环境可通过代理访问github;
  2. 进入nextcloud的应用页面,找到自己想装的拓展应用;
  3. 点击想要安装的应用展开详情,进入“访问网站”链接,此时一般会去到插件的github页面或者nextcloud官方发布插件页面
  4. 进入github项目的release页面,下载最新的插件更新版本到当前本机。按照nextcloud的插件发布标准应该是一个tar.gz文件;
  5. 将下载下来的文件从nextcloud个人文件页面上传到网盘中;
  6. 进入nextcloud容器。docker exec -u 33 -it [container ID or container name] /bin/bash,其中[container ID or container name]要换成真实容器的ID或名字;
  7. 到路径下找到自己上传的拓展插件。例如/var/www/html/data/[username]/files/nextcloud_extension/metadata.tar.gz,其中[username]要换成用户的名字。这里装的是matadata插件,用于查看图片各种元数据的;
  8. 将其复制到/var/www/html/appscp /var/www/html/data/[username]/files/nextcloud_extension/metadata.tar.gz /var/www/html/apps
  9. 解压后删除源压缩文件cd /var/www/html/apps && tar -xzf metadata.tar.gz && rm metadata.tar.gz
  10. 进入nextcloud页面的【应用】-【已禁用的应用】页面,将其启用。

按照以上步骤来操作就可以做到实现手动安装插件的目的了。

安装jellyfin(主要应用nextcloud的自动同步功能将自动下载的文件同步到服务器,然后服务器中的jellyfin调用)

运行 jellyfin container

这里使用yml文件配置来实现jellyfin的docker,我的机器是arm所以拉取LinuxServer.io提供的镜像,据说不仅小巧而且没有那么多漏洞,和权限。hwa等问题。

建立工作目录:

$ sudo mkdir -p /www/jellyfin/data/metadate #这里主要是为了方便管理,所有关于jellyfin的文件都会存放在jellyfin文件夹下
$ sudo chown -R 1000:1000 /www/jellyfin #修改权限,查了一下,这块主要是docker的系统机制,他并不是虚拟机,如果采用root权限,即不设置权限的话,存在一下安全问题,就是docker容器的权限会提升到root权限有些风险,所以按照这个权限配置uid为1000的用户组和用户。

定义container:

在jellyfin文件夹下创建一个yml文件:dc-jellyfin.yml

version: "3"

services:
  jellyfin:
    container_name: jellyfin
    image: linuxserver/jellyfin:latest
#    devices:
#      - /dev/vc-mem:/dev/vc-mem
#      - /dev/vchiq:/dev/vchiq
#    networks:
#      default:
#        ipv4_address: 192.168.0.201
network_mode: "host" #使用host方式,放弃vlan
    environment:
      PUID: 1000
      PGID: 1000
      TZ: Asia/Shanghai
#      HTTP_PROXY: "http://192.168.0.3:1081"
#      HTTPS_PROXY: "http://192.168.0.3:1081"
#      NO_PROXY: "127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,139.198.0.0/16,localhost"
    volumes:
      - /srv/jellyfin:/config
      - /media:/media
      - /opt/vc/lib:/opt/vc/lib
    restart: unless-stopped

#networks:
#  default:
#    external:
 #     name: ipvlan

因为我的机器gpu没有驱动,所以也就不想硬解了,其次代理问题也不用考虑,有路由跳墙,至于网络这块,实在弄不懂怎么划分vlan设置,就也抛弃。直接使用host。但是据说docker的bridge网络nat性能很差,所以等以后研究研究可以尝试配置一下。

启动container:

$ docker-compose -f dc-jellyfin.yml up --no-start
$ docker container start jellyfin

总结

经历了这次搭建网盘,算是初级入门了docker容器的部署,以及docker-compose的配置入门。

只能说,在开始一个项目之前,还有许多东西需要实现考虑和准备好,做好缺陷预防。这样在真正上手做的时候,才会尽可能的少出差错,以及处变不惊。

后记:

在我配置的时候因为修改nextcloud的config.php文件可能出现了操作失误,导致nextcloud出现内部错误,本来想全部重新来一遍的,想了想,既然只是nextcloud出了问题,直接删除nextcloud容器,重新建立一个,因为基本上配置文件都在外部,基本不影响,只需要重新设置一下账号密码以及数据库连接,(此处由于数据库也有nextcloud的问题,数据库也重建过一次,当然我们在删除容器之后也要把对应的数据文件夹,比如nextcloud对应的数据文件夹为app,app文件夹也要做整体删除才行。)

参考文献

https://www.jianshu.com/p/695fa3b0dab5

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
禁止转载,如需转载请通过简信或评论联系作者。
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 160,026评论 4 364
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,655评论 1 296
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,726评论 0 244
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,204评论 0 213
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,558评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,731评论 1 222
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,944评论 2 314
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,698评论 0 203
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,438评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,633评论 2 247
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,125评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,444评论 3 255
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,137评论 3 238
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,103评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,888评论 0 197
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,772评论 2 276
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,669评论 2 271

推荐阅读更多精彩内容