20

优化nextcloud

 4 years ago
source link: https://www.tuicool.com/articles/MZFbUfQ
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

前文 树莓派安装nextcloud搭建私有云 介绍了在树莓派上安装和部署nextcloud私有云的详细步骤。因nextcloud功能强大,执行过程中会消耗大量的系统资源,对于硬件能力不强的树莓派来说很有必要进行系统性的优化调整。

本文整理自官方教程,给出优化next的详细步骤。

  1. 用cron替代后台ajax刷新执行定时任务。执行命令: sudo echo '*/5 * * * * www-data php /var/www/html/nextcloud/cron.php' >> /etc/crontab ,注意 /var/www/html/nextcloud 应替换成你系统中nextcloud的根目录;
  2. 使用缓存。需要安装redis以及编辑nextcloud的配置文件,详情参考 树莓派安装nextcloud搭建私有云
  3. 优化mysqld。编辑 /etc/mysql/conf.d/mysql.cnf 文件,加入以下行:
    [mysqld]
     innodb_buffer_pool_size=256m
     innodb_io_capacity=4000
  4. 使用redis锁代替文件锁。安装redis,然后编辑nextcloud的配置文件,添加以下行:
    'filelocking.enabled' => true,
     'memcache.locking' => '\OC\Memcache\Redis',
  5. 配置php-fpm。编辑 /etc/php/7.3/fpm/pool.d/www.conf 文件,设置动态进程数量:
    pm.max_children = 50
     pm.start_servers = 3
     pm.min_spare_servers = 3
     pm.max_spare_servers = 10
  6. 启用opcache。安装opcache模块,在 /etc/php/7.3/fpm/php.ini 编辑opcache设置:
    opcache.enable=1
     opcache.interned_strings_buffer=8
     opcache.max_accelerated_files=10000
     opcache.memory_consumption=128
     opcache.save_comments=1
     opcache.revalidate_freq=30
  7. 启用大文件上传。编辑 /etc/php/7.3/fpm/php.ini ,更改文件限制:
    upload_max_filesize=16G
     post_max_size=16G
     max_input_time = 3600
     max_execute_time = 3600
     memory_limit = 512M
    接着编辑 /etc/nginx/nginx.conf ,在http块中修改上传限制:
    client_max_body_size 16G;
     fastcgi_read_timeout 360S;

参考

  1. https://docs.nextcloud.com/server/17/admin_manual/installation/server_tuning.html#using-cron-to-perform-background-jobs

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK