nextcloud
2021-08-28 / 2025-08-31 | ||
Install
Apache / HTTPS / PHP / MariaDB installieren
sudo apt install php-mysql php-apcu php-imagick php-intl php-bcmath php-gmp php-gd php-curl php-zip php-xml php-mbstring redis php-redis
# libmagickcore-6.q16-6-extra <- wird unter arm-debian nicht gefunden
cd /var/www/html
curl https://download.nextcloud.com/server/releases/nextcloud-17.0.1.tar.bz2 | sudo tar -jxv
mkdir -p /var/www/html/nextcloud/data
sudo chown -R www-data:users /var/www/html/
sudo chmod -R 770 /var/www/html/nextcloud/data
sudo service apache2 restart
mysql -u root -p
create database nextcloud;
CREATE USER nextcloud@localhost IDENTIFIED BY '♯crypt♯';
GRANT ALL PRIVILEGES ON nextcloud.* to nextcloud@localhost;
FLUSH PRIVILEGES;
exit;
Konfiguration
sudo nano /var/www/html/nextcloud/config/config.php
# unten einfügen
'memcache.local' => '\\OC\\Memcache\\APCu',
'memcache.distributed' => '\\OC\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => 'localhost',
'port' => 6379,
'timeout' => 0.0,
),
'filelocking.enabled' => 'true',
sudo nano /etc/php/8.4/apache2/php.ini
#Strg+W "OPC", in der Sektion diese Parameter anpassen:
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=1
opcache.save_comments=1
Strg+W "memory_limit"
memory_limit = 2048M
#Im 32Bit System kann keine 2GB zugiesen werden!
sudo nano /etc/php/8.4/apache2/conf.d/20-apcu.ini
# Einfügen
extension=apcu.so
apc.enabled=1
apc.shm_size=32M
apc.ttl=7200
apc.enable_cli=1
sudo crontab -u www-data -e
*/5 * * * * php -f /var/www/html/nextcloud/cron.php
Troubleshooting
Fehlende Indizes
cd /var/www/html/nextcloud/
sudo -u www-data php occ db:add-missing-indices
Fehlende Primärschlüssel
cd /var/www/html/nextcloud/
sudo -u www-data php occ db:add-missing-primary-keys
Fehlende Spalten
cd /var/www/html/nextcloud/
sudo -u www-data php occ db:add-missing-columns
Konvertierung big int
cd /var/www/html/nextcloud/
sudo -u www-data php occ db:convert-filecache-bigint
?
cd /var/www/html/nextcloud/
sudo -u www-data php occ maintenance:repair --include-expensive
Incorrect row format found in your database. ROW_FORMAT=Dynamic offers the best database performances for Nextcloud.
mysql -h localhost -u nextcloud -p'♯crypt♯' nextcloud
SELECT CONCAT('ALTER TABLE \`', TABLE_NAME, '\` ROW_FORMAT=DYNAMIC;') FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'nextcloud' AND ENGINE = 'InnoDB';
#Ergebnis ausführen...
maintenance_window_start
cd /var/www/html/nextcloud/
sudo -u www-data php occ config:system:set maintenance_window_start --type=integer --value=1
Enabling MariaDB 4-byte support
mysql -u root -p
ALTER DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
exit;
cd /var/www/html/nextcloud
sudo -u www-data php occ config:system:set mysql.utf8mb4 --type boolean --value="true"
sudo -u www-data php occ maintenance:repairy
Exception beim Laden der Seite "Apps"
cd /var/www/html/nextcloud/
sudo -u www-data php occ files:scan-app-data
sudo -u www-data php occ maintenance:repair
RewriteRule
cd /var/www/html
nano .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^\.well-known/host-meta /nextcloud/public.php?service=host-meta [QSA,L]
RewriteRule ^\.well-known/host-meta\.json /nextcloud/public.php?service=host-meta-json [QSA,L]
#RewriteRule ^\.well-known/webfinger /nextcloud/public.php?service=webfinger [QSA,L]
RewriteRule ^\.well-known/carddav /nextcloud/remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/caldav /nextcloud/remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/webfinger /nextcloud/index.php/.well-known/webfinger [R=301,L]
RewriteRule ^\.well-known/nodeinfo /nextcloud/index.php/.well-known/nodeinfo [R=301,L]
</IfModule>
Serverseitige Verschlüsselung, bestehende Dateien
cd /var/www/html/nextcloud/
sudo -u www-data php occ encryption:encrypt-all
Remove App with Commandline
sudo -u www-data php occ app:list
sudo -u www-data php occ app:disable NAME_OF_APP
sudo -u www-data php occ app:remove NAME_OF_APP
Externen Speicher einbinden
App External storage support aktivieren dann kann in der Konfiguration der Speicher eingebunden werden.
User umbenennen
Geht nicht...
Neuen User anlegen und Daten auf den neuen umziehen:
/var/www/html/nextcloud/sudo -u www-data php occ files:transfer-ownership
CleanUp appdata-Folder / Preview
sudo rm -r -f /var/www/html/nextcloud/data/heister.be/appdata_?!?!?/preview/*
sudo -u www-data /usr/bin/php /var/www/html/nextcloud/occ files:scan-app-data
.htaccess
#!!ACHTUNG!
# r4g9 braucht seine .htaccess zum umleiten in den nextcloud ordner
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^\.well-known/host-meta /nextcloud/public.php?service=host-meta [QSA,L]
RewriteRule ^\.well-known/host-meta\.json /nextcloud/public.php?service=host-meta-json [QSA,L]
#RewriteRule ^\.well-known/webfinger /nextcloud/public.php?service=webfinger [QSA,L]
RewriteRule ^\.well-known/carddav /nextcloud/remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/caldav /nextcloud/remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/webfinger /nextcloud/index.php/.well-known/webfinger [R=301,L]
RewriteRule ^\.well-known/nodeinfo /nextcloud/index.php/.well-known/nodeinfo [R=301,L]
</IfModule>
# NUR HTTPS zulassen:
RewriteCond %{SERVER_PORT} !^443
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Umleitung in default
RewriteRule ^$ https://%{HTTP_HOST}%{REQUEST_URI}/nextcloud [R=301,L]
Sicherung
cd /var/www/html/nextcloud
sudo -u www-data php occ maintenance:mode --on
tar -cf /media/nas/Sicherung/r4g9/nextcloud/NextcloudBackup_`date +"%Y%m%d"`.tar /var/www/html/nextcloud
mysqldump --single-transaction -h localhost -u nextcloud -p'♯crypt♯' nextcloud > /media/nas/Sicherung/r4g9/nextcloud/NextcloudBackup_`date +"%Y%m%d"`.sql
#sudo -u www-data php occ maintenance:mode --off
Rücksicherung
sudo rm -r /var/www/html/nextcloud/*
# Nur ein TAR-Sack darf da liegen!
sudo tar -xf NextcloudBackup_*.tar -C /
sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo chmod -R 774 /var/www/html/nextcloud
mysql -h localhost -u nextcloud -p'♯crypt♯' -e "DROP DATABASE nextcloud"
mysql -h localhost -u nextcloud -p'♯crypt♯' -e "CREATE DATABASE nextcloud"
# Nur ein SQL-Dump darf da liegen!
mysql -h localhost -u nextcloud -p'♯crypt♯' nextcloud < NextcloudBackup_*.sql
cd /var/www/html/nextcloud
sudo -u www-data php occ maintenance:mode --off
sudo -u www-data php occ maintenance:data-fingerprint
reboot