nextcloud使用中遇到的一些问题

任意问题解决大招:https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html

基于docker安装完nextcloud会提示一下错误,安全检查事项

#数据库丢失了一些索引。由于给大的数据表添加索引会耗费一些时间,因此程序没有自动对其进行修复。您可以在 Nextcloud 运行时通过命令行手动执行 “occ db:add-missing-indices” 命令修复丢失的索引。索引修复后会大大提高相应表的查询速度。
docker exec -u www-data -i nextcloud_app_1 php occ db:add-missing-indices

#此实例中的 php-imagick 模块不支持 SVG。为了获得更好的兼容性,建议安装它。
docker exec -i nextcloud_app_1 apt update && docker exec -i nextcloud_app_1 apt install imagemagick

#INVALID_HASH: core/js/mimetypelist.js in the list of invalid files
docker exec -i nextcloud_app_1 cp -av /usr/src/nextcloud/core/js/mimetypelist.js core/js/

#您的网页服务器未正确设置以解析“/.well-known/caldav”。更多信息请参见文档。
#您的网页服务器未正确设置以解析“/.well-known/carddav”。更多信息请参见文档。
#在nginx代理中添加
location = /.well-known/carddav {
  return 301 https://网盘域名:443/remote.php/dav;
}
location = /.well-known/caldav {
  return 301 https://网盘域名:443/remote.php/dav;
}
location = /.well-known/host-meta {
  return 301 https://网盘域名:443/public.php?service=host-meta;
}
location = /.well-known/host-meta.json {
  return 301 https://网盘域名:443/public.php?service=host-meta-json;
}
    location = /.well-known/webfinger {
  return 301 https://网盘域名:443/index.php/.well-known/webfinger;
}
    location = /.well-known/nodeinfo {
  return 301 https://网盘域名:443/index.php/.well-known/nodeinfo;
}

#如果是apache服务器,编辑/etc/apache2/sites-available/000-default.conf,增加下列
        <Directory />
           Options FollowSymLinks
           AllowOverride All
           Order deny,allow
           Deny from all
        </Directory>

        <Directory "/var/www/html">
           Options Indexes FollowSymLinks MultiViews
           AllowOverride All
           Order allow,deny
           Allow from all
        </Directory>

解决视频不显示缩略图

#安装ffmpeg
sudo apt-get install ffmpeg ghostscript
sudo service apache2 restart

#配置文件中增加
'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\PNG',
    1 => 'OC\\Preview\\JPEG',
    2 => 'OC\\Preview\\GIF',
    3 => 'OC\\Preview\\HEIC',
    4 => 'OC\\Preview\\BMP',
    5 => 'OC\\Preview\\XBitmap',
    6 => 'OC\\Preview\\MP3',
    7 => 'OC\\Preview\\TXT',
    8 => 'OC\\Preview\\MarkDown',
    9 => 'OC\\Preview\\Movie',
    9 => 'OC\\Preview\\PDF',
    9 => 'OC\\Preview\\MP4',
  ),

做完上述配置发现PDF缩略图还是没有显示成功

#通过日志发现pdf在做转换的时候出发了权限问题:ImagickException: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/421******

#编辑Imagick的配置文件
vi /etc/ImageMagick-6/policy.xml
'''
  <!-- disable ghostscript format types -->
  <policy domain="coder" rights="read|write" pattern="PS" />
  <policy domain="coder" rights="read|write" pattern="PS2" />
  <policy domain="coder" rights="read|write" pattern="PS3" />
  <policy domain="coder" rights="read|write" pattern="EPS" />
  <policy domain="coder" rights="read|write" pattern="PDF" />
  <policy domain="coder" rights="read|write" pattern="XPS" />
'''

#重启apache2服务
/etc/init.d/apache2 restart

nextcloud无法访问应用商店

#在使用中某些拉胯网络无法访问官方源,导致应用商店加载不出来
使用APP商店国内镜像
镜像地址:https://www.orcy.net/ncapps/v1/
github链接加速代理的镜像:https://www.orcy.net/ncapps/v2/

#在config.php中增加以下配置
'appstoreenabled' => true,
'appstoreurl' => 'https://www.orcy.net/ncapps/v2/',

设置默认语言和默认时区

  'default_language' => 'zh_CN',
  'default_locale' => 'zh',

使用redis缓存提高效率

#配置好redis,使用下列配置即可,如果有其他问题全力排查redis故障
  'memcache.local' => '\\OC\\Memcache\\redis',
  'memcache.distributed' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => [
       'host'     => '1.1.1.1',
       'port'     => 6379,
       'dbindex'  => 0,
       'password' => 'xxxxxx',
       'timeout'  => 1.5,
  ],

#php优化配置
redis.session.locking_enabled=1
redis.session.lock_retries=-1
redis.session.lock_wait_time=10000

nextcloud基于curl下载share文件

#基于分享连接实现非交互下载
#如果分享为整个目录
#可参考工具:https://github.com/aertslab/nextcloud_share_url_downloader
curl -u "SHARE_ID:SHARE_PASSWORD" -H 'X-Requested-With: XMLHttpRequest' -O "https://urls/public.php/webdav/xxxxxx.tgz"
#如果分享为单个文件
curl -u "SHARE_ID:SHARE_PASSWORD" -H 'X-Requested-With: XMLHttpRequest' -o xxxxxx.tgz "https://urls/public.php/webdav/"

nextcloud基于用户使用curl上传下载文件

#基于用户名密码实现非交互上传和下载
#upload
curl -X PUT -u yasu:<pass> https://urls/remote.php/dav/files/xxx/ -T ./image.jpg
#download
curl -X GET -u yasu:<pass> https://urls/remote.php/dav/files/xxx/Nextcloud.png --output Nextcloud.png

服务器上使用mv将文件更新到用户目录

#移动数据到用户目录下
mv bge-m3.tgz /$nextcloud_home/data/zhangsan/files/
#更新文件信息
docker exec -u www-data -i nextcloud_app_1 php occ files:scan --path=zhangsan

nextcloud配置文件config.php全览

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\redis',
  'memcache.distributed' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => [
       'host'     => '1.1.1.1',
       'port'     => 6379,
       'dbindex'  => 0,
       'password' => 'xxxxxxxx',
       'timeout'  => 1.5,
  ],
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'xxxxxgsvdlxg',
  'passwordsalt' => 'xxxxxxxxUJTczZLe2hWU/M0t',
  'secret' => 'xxxxxxxxxxmZxDgXGv43+rVAFXtL080VS7',
  'trusted_domains' => 
  array (
    0 => '192.168.2.181:8080',
    1 => 'xxx.xxxxx.com:8443',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '23.0.3.2',
  'overwrite.cli.url' => 'http://xxx.xxxxxx.com:8443',
  'forcessl' => true,
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxxxxxxx',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'default_language' => 'zh_CN',
  'default_locale' => 'zh',
  'mail_from_address' => 'xxxx',
  'mail_domain' => '126.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.126.com',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'xxxxxxxxx@126.com',
  'mail_smtppassword' => 'Oxxxxxxxxx',
  'mail_smtpsecure' => 'ssl',
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\PNG',
    1 => 'OC\\Preview\\JPEG',
    2 => 'OC\\Preview\\GIF',
    3 => 'OC\\Preview\\HEIC',
    4 => 'OC\\Preview\\BMP',
    5 => 'OC\\Preview\\XBitmap',
    6 => 'OC\\Preview\\MP3',
    7 => 'OC\\Preview\\TXT',
    8 => 'OC\\Preview\\MarkDown',
    9 => 'OC\\Preview\\Movie',
    10 => 'OC\\Preview\\PDF',
    11 => 'OC\\Preview\\MP4',
  ),
  'default_phone_region' => 'CN',
  'maintenance' => false,
  'loglevel' => 0,
  'theme' => '',
  'appstoreenabled' => true,
  'appstoreurl' => 'https://www.orcy.net/ncapps/v2/',
);

升级失败导致进入维护模式

#报错信息如下
#################
An unhandled exception has been thrown:
Error: Call to undefined method OCA\Music\Utility\Util::extractUserIds() in /var/www/html/custom_apps/music/lib/Utility/Scanner.php:392
Stack trace:
#0 /var/www/html/custom_apps/music/lib/Utility/Scanner.php(411): OCA\Music\Utility\Scanner->deleteImage(Array, NULL)
#1 /var/www/html/custom_apps/music/lib/Hooks/FileHooks.php(40): OCA\Music\Utility\Scanner->delete(64391)
#2 [internal function]: OCA\Music\Hooks\FileHooks::deleted(Object(OC\Files\Node\File))
#3 /var/www/html/lib/private/Hooks/EmitterTrait.php(88): call_user_func_array(Array, Array)
#4 /var/www/html/lib/private/Hooks/PublicEmitter.php(22): OC\Hooks\BasicEmitter->emit('\\OC\\Files', 'preDelete', Array)
#5 /var/www/html/lib/private/Files/Node/Root.php(126): OC\Hooks\PublicEmitter->emit('\\OC\\Files', 'preDelete', Array)
#6 /var/www/html/lib/private/Files/Node/Node.php(110): OC\Files\Node\Root->emit('\\OC\\Files', 'preDelete', Array)
#7 /var/www/html/lib/private/Files/Node/File.php(110): OC\Files\Node\Node->sendHooks(Array)
#8 /var/www/html/lib/private/Files/SimpleFS/SimpleFile.php(114): OC\Files\Node\File->delete()
#9 /var/www/html/lib/private/Template/JSCombiner.php(233): OC\Files\SimpleFS\SimpleFile->delete()
#10 /var/www/html/lib/private/Repair/ClearFrontendCaches.php(36): OC\Template\JSCombiner->resetCache()
#11 /var/www/html/lib/private/Repair.php(104): OC\Repair\ClearFrontendCaches->run(Object(OC\Repair))
#12 /var/www/html/lib/private/Updater.php(265): OC\Repair->run()
#13 /var/www/html/lib/private/Updater.php(100): OC\Updater->doUpgrade('31.0.8.1', '31.0.6.2')
#14 /var/www/html/core/Command/Upgrade.php(192): OC\Updater->upgrade()
#15 /var/www/html/3rdparty/symfony/console/Command/Command.php(326): OC\Core\Command\Upgrade->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/3rdparty/symfony/console/Application.php(1078): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/html/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(OC\Core\Command\Upgrade), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/html/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/html/lib/private/Console/Application.php(187): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/html/console.php(87): OC\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#21 /var/www/html/occ(33): require_once('/var/www/html/c...')
#22 {main}    0/0 [--->------------------------]   0%Warning: /var/www/html/config/apps.config.php differs from the latest version of this image at /usr/src/nextcloud/config/apps.config.php
Warning: /var/www/html/config/redis.config.php differs from the latest version of this image at /usr/src/nextcloud/config/redis.config.php
Warning: /var/www/html/config/reverse-proxy.config.php differs from the latest version of this image at /usr/src/nextcloud/config/reverse-proxy.config.php
Warning: /var/www/html/config/s3.config.php differs from the latest version of this image at /usr/src/nextcloud/config/s3.config.php
Warning: /var/www/html/config/smtp.config.php differs from the latest version of this image at /usr/src/nextcloud/config/smtp.config.php
Warning: /var/www/html/config/swift.config.php differs from the latest version of this image at /usr/src/nextcloud/config/swift.config.php
Warning: /var/www/html/config/upgrade-disable-web.config.php differs from the latest version of this image at /usr/src/nextcloud/config/upgrade-disable-web.config.php
=> Searching for hook scripts (*.sh) to run, located in the folder "/docker-entrypoint-hooks.d/before-starting"
==> Skipped: the "before-starting" folder is empty (or does not exist)
[15-Aug-2025 16:35:44] NOTICE: fpm is running, pid 1
[15-Aug-2025 16:35:44] NOTICE: ready to handle connections
11.111.96.4 -  15/Aug/2025:16:35:51 +0800 "GET /ocs/v2.php" 503
11.111.96.4 -  15/Aug/2025:16:35:50 +0800 "GET /index.php" 503
###################

#通过日志看出在升级时应用music导致升级失败,同时后端一些配置文件由于太老了缺少配置导致了警告,处理过程
#备份老的配置文件
mv /var/www/html/config /var/www/html/config.bak

cp /usr/src/nextcloud/config/apps.config.php /var/www/html/config/apps.config.php 
cp /usr/src/nextcloud/config/redis.config.php /var/www/html/config/redis.config.php
cp /usr/src/nextcloud/config/reverse-proxy.config.php /var/www/html/config/reverse-proxy.config.php
cp /usr/src/nextcloud/config/s3.config.php /var/www/html/config/s3.config.php
cp /usr/src/nextcloud/config/smtp.config.php /var/www/html/config/smtp.config.php
cp /usr/src/nextcloud/config/swift.config.php /var/www/html/config/swift.config.php
cp /usr/src/nextcloud/config/upgrade-disable-web.config.php /var/www/html/config/upgrade-disable-web.config.php

#关闭失败应用
php occ app:disable music

#关闭维护模式
php occ maintenance:mode --off

#升级服务
php occ upgrade
此条目发表在网盘分类目录。将固定链接加入收藏夹。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注