NextCloud终极优化,内网上传破100M/s优化) 您所在的位置:网站首页 zuisucloudcloud NextCloud终极优化,内网上传破100M/s优化)

NextCloud终极优化,内网上传破100M/s优化)

2024-06-27 17:38| 来源: 网络整理| 查看: 265

NextCloud终极优化,内网上传破100 一、系统性能优化(针对界面加载优化)二.上传速度优化

一、系统性能优化(针对界面加载优化)

性能优化的详细过程已完善,请移步 Nextcloud打开缓慢\卡顿的一些优化

Nextcloud由于各种原因,默认安装后,任何页面加载时间都过于缓慢。之前的文章有介绍到使用PHP的APCu模块以提升缓存性能,这里再介绍使用Memcached提高Nextcloud的性能。

Nextcloud支持多个不同类型的缓存后端,所以可以同时启用本地缓存(APCu)和分布式缓存(Memcached、Redis),官方推荐的组合是APCu+Redis

分布式缓存选择Memcached、Redis其中一种启用即可,无需两者都启用

宝塔面板很方便的可以安装php的Memcached和Redis模块(注意是memcached,非memcache),这里我以APCu+Memcached为例

安装完毕后,打开/www/wwwroot/你的nextcloud目录/config/config.php,在其尾部添加以下代码

第1行为指定本地缓存为APCu,第2、3行为指定分布式缓存为Memcached

‘memcache.local’ => ‘\OC\Memcache\APCu’, ‘memcache.distributed’ => ‘\OC\Memcache\Memcached’, ‘memcached_servers’ => array( array(‘localhost’, 11211), ) 如图,注意分号,保存即可

Redis则需要稍微修改一下配置

‘memcache.local’ => ‘\OC\Memcache\APCu’, ‘memcache.distributed’ => ‘\OC\Memcache\Redis’, ‘redis’ => array( ‘host’ => ‘localhost’, ‘port’ => 6379, ) 二、Nginx配置 这一步最为蛋疼,官方给出的Nginx配置示例,有些是可以参考的,有些挪到宝塔上来则会有各种奇奇怪怪的问题,所以需要针对宝塔修改nextcloud下Nginx的配置。

经过几天的折腾,这部分终于也解决的差不多了。分享一下我的Nginx配置,为方便理解和阅读,我已在配置文件中加入一些注释,可以根据情况修改一下即可。

server { #基础配置,这些可以照搬宝塔的配置 listen 80; listen 443 ssl http2; server_name file.bugxia.com; index index.php index.html index.htm default.php default.htm default.html; root /www/wwwroot/file.bugxia.com; client_max_body_size 10G; fastcgi_buffers 64 4K; 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;

#nextcloud包含了403和404的错误页面 error_page 403 /core/templates/403.php; error_page 404 /core/templates/404.php; #防止一些HTTP响应头引起的安全隐患 add_header Strict-Transport-Security 'max-age=15552000'; add_header X-Content-Type-Options 'nosniff'; add_header X-Robots-Tag 'none'; add_header X-Frame-Options 'SAMEORIGIN'; add_header X-Download-Options 'noopen'; add_header X-Permitted-Cross-Domain-Policies 'none'; add_header X-XSS-Protection '1;mode=block'; add_header Referrer-Policy "no-referrer"; #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 #error_page 404/404.html; ssl_certificate /www/server/panel/vhost/cert/file.bugxia.com/fullchain.pem; ssl_certificate_key /www/server/panel/vhost/cert/file.bugxia.com/privkey.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; error_page 497 https://$host$request_uri; #SSL-END #PHP-INFO-START PHP引用配置,可以注释或修改 #include enable-php-74.conf; #PHP-INFO-END #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效 include /www/server/panel/vhost/rewrite/file.bugxia.com.conf; #REWRITE-END 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; } location / { rewrite ^ /index.php; } #Let's Encrypt 证书续期验证目录 location ~ \.well-known{ allow all; } #nextcloud一些关键目录的权限设置 location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ { deny all; } location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) { deny all; } location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(\/.*|)$; set $path_info $fastcgi_path_info; try_files $fastcgi_script_name =404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $path_info; fastcgi_param HTTPS on; fastcgi_param modHeadersAvailable true; #宝塔默认是include调用PHP相关配置,这里稍稍修改了一下,注意php版本 #加入了front_controller_active这项参数以隐藏页面URL中的index.php fastcgi_param front_controller_active true; fastcgi_pass unix:/tmp/php-cgi-74.sock; fastcgi_intercept_errors on; fastcgi_request_buffering off; include fastcgi.conf; include pathinfo.conf; } location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) { try_files $uri/ =404; index index.php; } location ~ \.(?:css|js|woff2?|svg|gif|map)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463"; add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Download-Options "noopen" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "none" always; add_header X-XSS-Protection "1; mode=block" always; access_log off; } location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ { try_files $uri /index.php$request_uri; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; error_log off; access_log /dev/null; } location ~ .*\.(js|css)?$ { expires 12h; error_log off; access_log /dev/null; }

以上内容是转载,原文链接:https://bugxia.com/197.html

二.上传速度优化

配置过nextcloud的小伙伴可能有感觉,不做任何优化的时候,nextcloud的上传速度就10M/左右,哪怕内网千兆的带宽也是如此。不怕,按以下优化即可。 1.进入docker(如果是实体机安装的,请以root用户登录,跳过这一步。)

docker exec -u 1000 容器id bash

注:-u 1000是以管理员用户登录进docker的 2.找到nextcloud的安装文件见,我们搜occ来找

find / -name 'occ'

找到nextcloud的目录后,成都进入该目录 在这里插入图片描述 3.执行以下语句

php occ config:app:set files max_chunk_size --value 0(解除块大小限制)

优化完成,试一试上传速度 在这里插入图片描述 OK,完美



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有