#安装环境:centos7,宝塔面板5.9,apache2.4、php7.0、mysql5.5,php开启pathinfo,opcache,apcu,redis缓存。

#以下是在上述环境中,可能遇到的错误。
#nextcloud版本14.0.3(新版本外部存储插件不支持挂载google drive,如果需要此功能 安装12.0.5)
#nextcloud历史版本:https://nextcloud.com/changelog/

#因为宝塔的权限问题 .user.ini可能不能被覆盖,手动删除。

#PHP 的组件 OPcache 没有正确配置。
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

#没有安装 "smbclient". 无法挂载 "SMB / CIFS", "SMB / CIFS 使用 OC 登录信息". 请联系您的系统管理员安装.
yum -y install libsmbclient libsmbclient-devel
pecl install smbclient
#可能出现的错误
#-bash: pecl: command not found
yum install -y php-devel php-pear
#WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
pear upgrade --force PEAR
#如果出现上面错误,解决后重新执行
pecl install smbclient
#面板重启php-fpm

#HTTP的请求头 "Strict-Transport-Security" 未设置为至少 "15552000" 秒. 为了提高安全性,建议参照security tips ↗中的说明启用HSTS.
#HTTP的请求头 "Referrer-Policy" 未设置为 "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". 这会导致信息泄露.
#网站-设置-配置文件 <VirtualHost *:443>下面添加(如果不开启ssl,添加到80)
    <IfModule mod_headers.c>
      Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
      Header always set Referrer-Policy no-referrer
    </IfModule>

#内存缓存未配置,为了提升使用体验,请尽量配置内存缓存。
#config/config.php 最后一行之前添加
  'memcache.local' => '\OC\Memcache\APCu',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),

#Use of the the built in php mailer is no longer supported. Please update your email server settings
配置电子邮件服务器

#后台任务 建议选择webcron或cron(推荐systemd)
#webcron
宝塔后台-计划任务-任务类型:访问url

#cron crontab(和下面的2选1)
#编辑
crontab -u www -e
#写入
*/15 * * * * /www/server/php/70/bin/php -f /www/wwwroot/网站目录/cron.php
#检查任务计划
crontab -u www -l


#cron systemd(和上面的2选1)
#编辑
vi /etc/systemd/system/nextcloudcron.service
#写入:
[Unit]
Description=Nextcloud cron.php job

[Service]
User=www
ExecStart=/www/server/php/70/bin/php -f /www/wwwroot/网站目录/cron.php

[Install]
WantedBy=basic.target
#编辑
vi /etc/systemd/system/nextcloudcron.timer
#写入
[Unit]
Description=Run Nextcloud cron.php every 15 minutes

[Timer]
OnBootSec=5min
OnUnitActiveSec=15min
Unit=nextcloudcron.service

[Install]
WantedBy=timers.target

#启动计时器
systemctl start nextcloudcron.timer
#开机启动
systemctl enable nextcloudcron.timer
#nginx环境 相似问题参考上面的lamp

#PHP的安装似乎不正确,无法访问系统环境变量。getenv("PATH")函数测试返回了一个空值。
#/www/server/php/70/etc/php–fpm.conf 添加
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
#nginx伪静态规则
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
add_header Referrer-Policy no-referrer always;

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

location
~ ^/(data|config|.ht|db_structure.xml|README) {
deny all;
}
Last modification:April 15, 2022
如果觉得我的文章对你有用,请随意赞赏