在Virmach从Colocrossing机房搬离两年后,Virmach再次迎来大变故,由于其上游DediPath倒闭Virmach不得不开始维护。...
2024-11-26 2
#扫描所有用户的所有文件,并更新索引。
sudo -u www php occ files:scan --All
注意 PHP 和 OCC 文件路径,也可以直接写绝对路径:
sudo -u www /usr/local/php8.0/bin/php /hoMe/wwwroot/www.example.com/occ files:scan --all
#只扫描指定用户或者指定文件夹,并更新索引。
列出所有用户:
sudo -u www php occ user:list
只扫描 test 用户的文件:
sudo -u www php occ files:scan test
扫描用户的指定目录:
sudo -u www php occ files:scan --path="/test/files/download"
二、Nextcloud 伪静态规则
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;
# HTTP response headers borrowed from Nextcloud `.htaccess`
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;
# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;
#原有的基础上添加 /index.php$request_uri;
index index.php index.html /index.php$request_uri;
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
location = / {
if ( $http_user_agent ~ ^DavClnt ) {
return 302 /remote.php/webdav/$is_args$args;
}
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ^~ /.well-known {
# The rules in this block are an adaptation of the rules
# in `.htaccess` that concern `/.well-known`.
location = /.well-known/carddav { return 301 /remote.php/dav/; }
location = /.well-known/caldav { return 301 /remote.php/dav/; }
location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
location /.well-known/pki-validation { try_files $uri $uri/ =404; }
# Let Nextcloud's API for `/.well-known` URIs handle all other
# requests by passing them to the front-end controller.
return 301 /index.php$request_uri;
}
# Rules borrowed from `.htaccess` to hide certain paths from clients
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
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; # Avoid sending the security headers twice
fastcgi_param front_controller_active true; # Enable pretty urls
fastcgi_pass unix:/tmp/php-cgi.sock; #自行修改为对应路径
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
location ~ \.(?:css|js|svg|gif|png|jpg|ico)$ {
try_files $uri /index.php$request_uri;
expires 6M; # Cache-Control policy borrowed from `.htaccess`
access_log off; # Optional: Don't log access to assets
}
location ~ \.woff2?$ {
try_files $uri /index.php$request_uri;
expires 7d; # Cache-Control policy borrowed from `.htaccess`
access_log off; # Optional: Don't log access to assets
}
# Rule borrowed from `.htaccess`
location /remote {
return 301 /remote.php$request_uri;
}
location / {
try_files $uri $uri/ /index.php$request_uri;
}
三:解决423 locked
#临时解决方法
进入维护模式:
sudo -u www php occ maintenance:mode --on
清空 oc_file_locks 表:
delete * from oc_file_locks;
或者
truncate table oc_file_locks;
退出维护模式:
sudo -u www php occ maintenance:mode --off
#彻底解决方法
参考官网:https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html?highlight=cache
为 Nextcloud 配置 Redis 缓存,在 config/config.php 文件中添加以下配置:
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
'user' => 'Redis用户名',
'password' => 'Redis密码',
'dbindex' => 0,
'Timeout' => 1.5,
'read_timeout' => 1.5,
]
四:性能优化
#内存缓存优化
APCu(官方推荐):
安装PHP的APCu扩展,在 config/config.php 文件中添加以下配置:
'memcache.local' => '\OC\Memcache\APCu',
Redis(官方说多服务器可能导致问题,单机速度不如APCu):
'memcache.local' => '\OC\Memcache\Redis',
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
'user' => 'Redis用户名',
'password' => 'Redis密码',
'dbindex' => 0,
'timeout' => 1.5,
'read_timeout' => 1.5,
]
#PHP优化
upload_max_filesize 5G
post_max_size 5g
max_input_time 3600
max_execution_time 3600
memory_limit = 512M
output_buffering = 0
upload_tmp_dir = /dev/shm/client_body_temp
#NGINX优化
client_max_body_size 5G
fastcgi_read_timeout 3600
client_body_temp_path /dev/shm/client_body_temp
临时文件目录设置为内存时,推荐大内存服务器,务必配置 SWAP。
#如果 Nextcloud 位于 cdn 或者负载均衡后
有前端权限:建议关闭proxy_buffering或增加proxy_max_temp_file_size的值。
无前端权限:add_header X-Accel-Buffering no;
#高上传带宽环境中提高上传性能,调整 Nextcloud 端的块大小(默认为10M)
sudo -u www php occ config:app:set files max_chunk_size --value 20971520
AD:
【一个萌萌哒广告位】 FUNCDN真正亚洲优化CDN,电信CN2 / 联通CU / 移动CM A+级频宽高速接驳。 未经允许不得转载: 主机资讯-vps商家前沿资讯 » Nextcloud更新索引、伪静态、性能优化 Nextcloud Nextcloud伪静态规则 Nextcloud性能优化
相关文章
在Virmach从Colocrossing机房搬离两年后,Virmach再次迎来大变故,由于其上游DediPath倒闭Virmach不得不开始维护。...
2024-11-26 2
Softbank到中国联通已经炸了有大半年了(最近电信也炸了),目前根据搬瓦工方面的消息,软银预计将在2024年2月完成修复。 Hello,...
2024-11-26 1
2023年3月29日起腾讯云将调整所有海外轻量应用服务器套餐配置和价格。 一、香港轻量应用服务器通用型实例将全面取消,低价香港轻量服务器将不复存...
2024-11-26 0
微林是一个为开发者而生的小众云服务平台,成立于2014年,特色是提供 vxTrans 流量优化服务(L4)、Pivot 超导中枢服务(Link/Frp...
2024-11-26 2
PS:继OneinStack一键包被投毒事件后,LNMP.ORG军哥的一键包也被投毒,如有使用该程序的站长和企业请立即排查是否中招。 事件公告...
2024-11-26 1
在 2022 年 NAB 展会流媒体峰会上,Google 宣布 (https://cloud.google.com/blog/products/net...
2024-11-26 1
根据主机资讯掌握的最新情报,DMIT 可能在下一代后台面板升级后提供VM快照和备份服务。 官方网站:www.dmit.io 由于PVE的设...
2024-11-26 1
3.5、5、10 刀 免费升级为了2核CPU,并且CPU型号由Intel(R Xeon(R CPU E5-2676 v3 @ 2.40GHz 调整...
2024-11-26 1