linux  projekt  self-hosted

nextcloud

 

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=512
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=100000
opcache.revalidate_freq=1
opcache.save_comments=1
;JIT - einfügen
opcache.jit = 1255
opcache.jit_buffer_size = 8M

Strg+W "memory_limit"
memory_limit = 4096M
#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

Collaborative Open-Source Document Editing

Install

mkdir -p /etc/apt/keyrings && cd /etc/apt/keyrings
sudo wget -O collaboraonline-release-keyring.gpg https://collaboraoffice.com/downloads/gpg/collaboraonline-release-keyring.gpg

sudo nano /etc/apt/sources.list.d/collaboraonline.sources
    Types: deb
    URIs: https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-deb
    Suites: ./
    Signed-By: /etc/apt/keyrings/collaboraonline-release-keyring.gpg

update
install coolwsd code-brand collaboraoffice*de

Konfiguration

#sudo nano /etc/coolwsd/coolwsd.xml
sudo coolconfig set ssl.enable false
sudo coolconfig set ssl.termination true
sudo coolconfig set storage.wopi.host nextcloud.r4g9.l11
sudo coolconfig set-admin-password

sudo systemctl restart coolwsd
sudo nano /etc/apache2/sites-available/000-default-ssl.conf
#nextcode.r4g9.l11
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        ServerName nextcode.r4g9.l11

#        DocumentRoot /var/www/html/
#         SSLProxyEngine On
#         SSLProxyVerify none
#         SSLProxyCheckPeerCN off
#         SSLProxyCheckPeerName off
#         SSLProxyCheckPeerExpire off

        Options -Indexes

        # Encoded slashes need to be allowed
        AllowEncodedSlashes NoDecode

        # keep the host
        ProxyPreserveHost On

        # static html, js, images, etc. served from coolwsd
        # loleaflet/browser is the client part of Collabora Online
        ProxyPass           /loleaflet http://127.0.0.1:9980/loleaflet retry=0
        ProxyPassReverse    /loleaflet http://127.0.0.1:9980/loleaflet
        ProxyPass           /browser http://127.0.0.1:9980/browser retry=0
        ProxyPassReverse    /browser http://127.0.0.1:9980/browser

        # WOPI discovery URL
        ProxyPass           /hosting/discovery http://127.0.0.1:9980/hosting/discovery retry=0
        ProxyPassReverse    /hosting/discovery http://127.0.0.1:9980/hosting/discovery

        # Capabilities
        ProxyPass           /hosting/capabilities http://127.0.0.1:9980/hosting/capabilities retry=0
        ProxyPassReverse    /hosting/capabilities http://127.0.0.1:9980/hosting/capabilities

        # Main websocket
        ProxyPassMatch "/cool/(.*)/ws$" ws://127.0.0.1:9980/cool/$1/ws nocanon

        # Admin Console websocket
        ProxyPass   /cool/adminws ws://127.0.0.1:9980/cool/adminws

        # Download as, Fullscreen presentation and Image upload operations
        ProxyPass           /cool http://127.0.0.1:9980/cool
        ProxyPassReverse    /cool http://127.0.0.1:9980/cool

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        SSLEngine on

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                        SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                        SSLOptions +StdEnvVars
        </Directory>

        SSLCertificateFile /etc/ssl/certs/apache.crt
        SSLCertificateKeyFile /etc/ssl/private/apache.key
</VirtualHost>

sudo systemctl restart apache2

Troubleshooting

sudo systemctl status coolwsd

sudo journalctl -u coolwsd

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

Repair-Wundertüte...?

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
mysqldump --single-transaction -h localhost -u nextcloud -p'♯crypt♯' nextcloud >  NextcloudBackup_`date +"%Y%m%d"`.sql
#tar -cf ~/NextcloudBackup_`date +"%Y%m%d"`.tar /var/www/html/nextcloud
tar -cf ~/var-www-html-Backup_`date +"%Y%m%d"`.tar /var/www/html/
#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
 beCloudy   content   linux   myCloud   projekt   self-hosted   webserver