Last update at :2024-03-12,Edit by888u
1. After directly uploading or synchronizing files to the server, update the file index
#Scan all files for all users and update the index.
sudo -u www php occ files:scan --allPay attention to the PHP and OCC file paths, you can also write the absolute path directly:
sudo -u www /usr/local/php8.0/bin/php /home/wwwroot/www.example.com/occ files:scan --all#Only scan the specified user or specified folder and update the index.
List all users:
sudo -u www php occ user:listOnly scan files of test user:
sudo -u www php occ files:scan testScan the user's specified directory:
sudo -u www php occ files:scan --path="/test/files/download"2. Nextcloud pseudo-static rules
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; #Add /index.php$request_uri on the original basis; 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; #Modify it to the corresponding path 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; }Three: Solving 423 locked
#Temporary solution
Enter maintenance mode:
sudo -u www php occ maintenance:mode --onClear the oc_file_locks table:
delete * from oc_file_locks; or truncate table oc_file_locks;Exit maintenance mode:
sudo -u www php occ maintenance:mode --off#Complete solution
Refer to the official website: https ://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html?highlight=cache
Configure Redis cache for Nextcloud, add the following configuration in the config/config.php file:
'memcache.locking' => '\OC\Memcache\Redis', 'redis' => [ 'host' => '127.0.0.1', 'port' => 6379, 'user' => 'Redis username', 'password' => 'Redis password', 'dbindex' => 0, 'timeout' => 1.5, 'read_timeout' => 1.5, ]Four: Performance Optimization
#Memory cache optimization
APCu (official recommendation):
Install the APCu extension for PHP and add the following configuration in the config/config.php file:
'memcache.local' => '\OC\Memcache\APCu',Redis (officially said that multiple servers may cause problems, and the single-machine speed is not as good as 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 username', 'password' => 'Redis password', 'dbindex' => 0, 'timeout' => 1.5, 'read_timeout' => 1.5, ]#PHP optimization
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#NGINXOptimization
client_max_body_size 5G fastcgi_read_timeout 3600 client_body_temp_path /dev/shm/client_body_tempWhen the temporary file directory is set to memory, a large memory server is recommended and SWAP must be configured.
#If Nextcloud is behind a CDN or load balancing
With front-end permissions: It is recommended to turn off proxy_buffering or increase the value of proxy_max_temp_file_size.
No front-end permission: add_header X-Accel-Buffering no;
#Improve upload performance in high upload bandwidth environment, adjust the block size on Nextcloud side (default is 10M)
sudo -u www php occ config:app:set files max_chunk_size --value 20971520Recommended site searches: Hong Kong cn2 server, Hong Kong server defense, registration-free cdn, telecommunications host rental, dynamic ip server, German server, domain name registration information query jsp virtual host, free registration of website domain name, enterprise virtual host,
发表评论