docker搭建nextCloud
docker直接安装
docker pull nextcloud # 拉取nextcloud镜像
docker run -d --restart=always -p 8888:80 -v /usr/local/src/other/nextcloud:/var/www/html --name nextcloud nextcloud
-d 后台进程运行
-p 映射端口, 将容器80端口映射为主机的8888端口,可以自行修改端口,不过防火墙需要放通。
-v 挂载目录,将容器/var/www/html挂载到主机/mnt/sde/nextcloud下面
--name 名称,指定容器的名称为nextcloud
nextcloud 使用的基础镜像。
docker-compose方式安装
docker-compose.yml文件
version: "3"
services:
app:
image: nextcloud
container_name: nextcloud
privileged: true #获取宿主机root权限(特殊权限)
restart: always
ports:
- 9098:80
volumes:
- /usr/local/src/other/nextcloud:/var/www/html #/var/www/html 是nextcloud默认目录,数据及配置在在里面
- /usr/local/src/other/nextcloud/data:/var/www/html/data
- /usr/local/src/other/nextcloud/config:/var/www/html/config
extra_hosts:
- "dockerhost:192.168.1.123" # 宿主机的内网IP,便于容器内访问宿主机网络。dockerhost直接可以解析为192.168.1.123
/usr/local/src/other/nextcloud目录下执行
docker-compose up --build -d
数据库创建数据库与用户(坑!)
不能直接用root连接,会一直连接失败,需要提前创建一个用户给nextcloud连接,并开放远程连接权限
1、进入数据库
mysql -uroot -p
2、创建数据库
CREATE DATABASE IF NOT EXISTS next_cloud;
3、进入mysql数据库
use mysql;
4、创建用户并设置权限
CREATE USER 'next_cloud_admin'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON next_cloud.* TO 'next_cloud_admin'@'%' IDENTIFIED BY 'password';
5、刷新权限
FLUSH PRIVILEGES;
网页配置
http://ip:8888, 这个是刚刚配置的服务器地址加上刚刚映射的主机端口。
输入用户名密码,数据库使用MYSQL,数据库以后用户密码,数据库nextcloud,地址写内部地址192.168.1.123
然后安装指示一路填写信息,安装就好了。
错误
如果提示不信任域名访问
vim /mnt/sde/nextcloud/config/config.php 编辑配置文件。
0 =>'10.10.0.212:8888',添加。
重启容器服务
docker restart nextcloud 。
完成。
设置nextcloud允许https域名
如果不设置 https会访问不了
打开文件config.php
添加一句话:
'overwriteprotocol' => 'https',
docker 重启nextcoud
docker restart nextcloud
Nextcloud 多次无效登录尝试 / 登录缓慢问题解决方法
问题描述:
- 报错 “我们检测到您的 IP 进行了多次无效登录尝试。因此,你的下一次登录最长会延迟 30 秒。”
图 1 多次无效登录尝试
- 单击
登录按钮
后等待时间较长才载入主页面
解决办法:
其实造成这个问题的原因是因为 nextcloud 本身自带的防止暴力破解密码的策略造成的,如下为开发文档相关内容
'auth.bruteforce.protection.enabled' => true,
Whether the bruteforce protection shipped with Nextcloud should be enabled or not.
Disabling this is discouraged for security reasons.
Defaults to true
-
打开 config.php 文件找到
'auth.bruteforce.protection.enabled' => true,
这一行,将true
修改为false
-
如
config.php
配置文件无此行,则添加一行,如下
'auth.bruteforce.protection.enabled' => false,
文件上传大小设置
本文由 简悦 SimpRead 转码, 原文地址 help.nextcloud.com ![]
Nextcloud version: 24.0.7
Operating system and version : Ubuntu 22.04 LTS
Apache or nginx version : Apache/2.4.52 (Ubuntu)
PHP version : PHP 8.1.2-1ubuntu2.9
I followed the big file upload documentation page: https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html 5
Namely:
- added in var/www/html/.htaccess
# PHP 8+
<IfModule mod_php.c>
php_value mbstring.func_overload 0
php_value default_charset 'UTF-8'
php_value output_buffering 0
php_value upload_max_filesize 50G
php_value post_max_size 50G
php_value max_input_time 3600
php_value max_execution_time 3600
<IfModule mod_env.c>
SetEnv htaccessWorking true
</IfModule>
</IfModule>
- added in var/www/html/.user.ini:
php_value upload_max_filesize 50G
php_value post_max_size 50G
php_value max_input_time 3600
php_value max_execution_time 3600
- In /var/www/html/config/config.php:
modified the temp folder to have enough space by adding:
'tempdirectory' => '/var/www/html/data/temp/',
- changed chunk file to 20MB in Nextcloud:
sudo -u www-data php occ config:app:set files max_chunk_size --value 20971520
(not modified:
Apache
LimitRequestBody
SSLRenegBufferSize
Timeout
)
I tried to ulpload a 1GB or 3GB file and I have this error:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 81788960 bytes) at /var/www/html/3rdparty/guzzlehttp/psr7/src/Stream.php#247
The output of your Apache/nginx/system log in /var/log/____
:
[Wed Jan 11 14:26:18.460650 2023] [php:error] [pid 648113] [client 188.62.25.232:56863] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65011744 bytes) in /var/www/html/3rdparty/guzzlehttp/psr7/src/Stream.php on line 247
[Wed Jan 11 14:26:18.486268 2023] [php:error] [pid 648113] [client 188.62.25.232:56863] PHP Fatal error: Uncaught Error: Class "OCP\\Files\\Cache\\CacheEntryUpdatedEvent" not found in /var/www/html/lib/private/Files/Cache/Cache.php:418\nStack trace:\n#0 /var/www/html/lib/private/Files/ObjectStore/ObjectStoreStorage.php(487): OC\\Files\\Cache\\Cache->update()\n#1 [internal function]: OC\\Files\\ObjectStore\\ObjectStoreStorage->OC\\Files\\ObjectStore\\{closure}()\n#2 /var/www/html/3rdparty/icewind/streams/src/CountWrapper.php(100): call_user_func()\n#3 [internal function]: Icewind\\Streams\\CountWrapper->stream_close()\n#4 {main}\n thrown in /var/www/html/lib/private/Files/Cache/Cache.php on line 418
[Wed Jan 11 15:53:46.414047 2023] [php:error] [pid 655118] [client 188.62.25.232:62296] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 94371872 bytes) in /var/www/html/3rdparty/guzzlehttp/psr7/src/Stream.php on line 247
[Wed Jan 11 15:53:46.438177 2023] [php:error] [pid 655118] [client 188.62.25.232:62296] PHP Fatal error: Uncaught Error: Class "OCP\\Files\\Cache\\CacheEntryUpdatedEvent" not found in /var/www/html/lib/private/Files/Cache/Cache.php:418\nStack trace:\n#0 /var/www/html/lib/private/Files/ObjectStore/ObjectStoreStorage.php(487): OC\\Files\\Cache\\Cache->update()\n#1 [internal function]: OC\\Files\\ObjectStore\\ObjectStoreStorage->OC\\Files\\ObjectStore\\{closure}()\n#2 /var/www/html/3rdparty/icewind/streams/src/CountWrapper.php(100): call_user_func()\n#3 [internal function]: Icewind\\Streams\\CountWrapper->stream_close()\n#4 {main}\n thrown in /var/www/html/lib/private/Files/Cache/Cache.php on line 418
Thank you in advance for your help.
Nobody experienced the same difficulties?
Any help is appreciated…