Wie man NextCloud unter Debian 10 installiert

NextCloud ist ein kostenloser und quelloffener File-Hosting- und File-Sharing-Server, der aus dem ownCloud-Projekt hervorgegangen ist. Es ist anderen File-Sharing-Diensten wie Google Drive, Dropbox und iCloud sehr ähnlich. NextCloud ermöglicht es Ihnen, Dateien, Dokumente, Bilder, Filme und Videos von einem zentralen Standort aus zu speichern. Mit NextCloud können Sie Dateien, Kontakte und beliebige andere Medien mit Ihren Freunden und Kunden teilen. NextCloud lässt sich mit Mail, Kalender, Kontakten und anderen Funktionen integrieren, die Ihren Teams helfen, ihre Arbeit schneller und einfacher zu erledigen. Sie können den NextCloud-Client auf einem Desktop-Computer installieren, um Dateien mit Ihrem Nextcloud-Server zu synchronisieren. Desktop-Clients sind für die meisten Betriebssysteme verfügbar, darunter Windows, MacOS, FreeBSD und Linux.

In diesem Tutorial werden wir erklären, wie man NextCloud installiert und mit Let’s Encrypt SSL unter Debian 10 sichert.

Voraussetzungen

  • Ein Server, auf dem Debian 10 läuft.
  • Ein gültiger Domainname, der auf Ihre Server-IP zeigt. In diesem Tutorial verwenden wir die Domain nextcloud.example.com.
  • Auf Ihrem Server ist ein Root-Passwort konfiguriert.

Apache, MariaDB und PHP installieren

NextCloud läuft auf dem Webserver, ist in PHP geschrieben und verwendet MariaDB zur Speicherung ihrer Daten. Sie müssen also Apache, MariaDB, PHP und andere erforderliche Pakete auf Ihrem System installieren. Sie können sie alle installieren, indem Sie den folgenden Befehl ausführen:

apt-get install apache2 libapache2-mod-php mariadb-server php-xml php-cli php-cgi php-mysql php-mbstring php-gd php-curl php-zip wget unzip -y

Wenn alle Pakete installiert sind, öffnen Sie die Datei php.ini und passen Sie einige empfohlene Einstellungen an:

nano /etc/php/7.3/apache2/php.ini

Ändern Sie die folgenden Einstellungen:

memory_limit = 512M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 300
date.timezone = Asia/Kolkata

Speichern und schließen Sie die Datei, wenn Sie fertig sind. Starten Sie dann den Apache- und MariaDB-Dienst und ermöglichen Sie ihnen, nach dem Systemneustart mit dem folgenden Befehl zu starten:

systemctl start apache2
 systemctl start mariadb
 systemctl enable apache2
 systemctl enable mariadb

Wenn Sie fertig sind, können Sie mit dem nächsten Schritt fortfahren.

Datenbank für NextCloud konfigurieren

Als nächstes müssen Sie eine Datenbank und einen Datenbankbenutzer für NextCloud erstellen. Melden Sie sich dazu mit folgendem Befehl an der MariaDB-Shell an:

mysql -u root -p

Geben Sie Ihr Root-Passwort ein, wenn Sie dazu aufgefordert werden, und erstellen Sie dann eine Datenbank und einen Benutzer mit dem folgenden Befehl:

MariaDB [(none)]> CREATE DATABASE nextclouddb;
 MariaDB [(none)]> CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'password';

Als nächstes gewähren Sie dem nextclouddb mit dem folgenden Befehl alle Privilegien:

MariaDB [(none)]> GRANT ALL ON nextclouddb.* TO 'nextclouduser'@'localhost';

Als nächstes werden die Privilegien geflushed und die MariaDB-Shell mit dem folgenden Befehl verlassen:

MariaDB [(none)]> FLUSH PRIVILEGES;
 MariaDB [(none)]> EXIT;

Wenn Sie fertig sind, können Sie mit dem nächsten Schritt fortfahren.

NextCloud herunterladen

Besuchen Sie zunächst die NextCloud-Downloadseite und laden Sie die neueste Version der NextCloud auf Ihr System herunter. Zum Zeitpunkt der Erstellung dieses Artikels ist die neueste Version von NextCloud 17.0.1. Sie können es mit dem folgenden Befehl herunterladen:

wget https://download.nextcloud.com/server/releases/nextcloud-17.0.1.zip

Sobald der Download abgeschlossen ist, entpacken Sie die heruntergeladene Datei mit dem folgenden Befehl:

unzip nextcloud-17.0.1.zip

Als nächstes verschieben Sie das extrahierte Verzeichnis in das Apache-Web-Stammverzeichnis:

mv nextcloud /var/www/html/

Als nächstes geben Sie die richtigen Berechtigungen für das nextcloud-Verzeichnis mit dem folgenden Befehl:

chown -R www-data:www-data /var/www/html/nextcloud/
 chmod -R 755 /var/www/html/nextcloud/

Sobald Sie fertig sind, können Sie mit dem nächsten Schritt fortfahren.

Apache für NextCloud konfigurieren

Als Nächstes müssen Sie eine Konfigurationsdatei für den virtuellen Apache-Host erstellen, um NextCloud zu bedienen. Sie können sie mit dem folgenden Befehl erstellen:

nano /etc/apache2/sites-available/nextcloud.conf

Fügen Sie die folgenden Zeilen hinzu:

<VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/nextcloud/
     ServerName nextcloud.example.com

     Alias /nextcloud "/var/www/html/nextcloud/"

     <Directory /var/www/html/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud
     </Directory>

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

</VirtualHost>

Speichern und schließen Sie die Datei, wenn Sie fertig sind. Aktivieren Sie dann die virtuelle Apache-Hostdatei und andere erforderliche Module mit den folgenden Befehlen:

a2ensite nextcloud.conf
 a2enmod rewrite
 a2enmod headers
 a2enmod env
 a2enmod dir
 a2enmod mime

Starten Sie schließlich den Apache-Dienst neu, um die neue Konfiguration anzuwenden:

systemctl restart apache2

Sichere NextCloud mit Let’s Encrypt Free SSL

NextCloud ist jetzt installiert und konfiguriert. Als nächstes wird empfohlen, es mit Let’s Encrypt free SSL zu sichern. Installieren Sie dazu zunächst den Certbot-Client mit folgendem Befehl:

apt-get install python-certbot-apache -y

Nach der Installation können Sie den folgenden Befehl ausführen, um Let’s Encrypt Certificate für Ihre Domain nextcloud.example.com zu installieren.

certbot --apache -d nextcloud.example.com

Während der Installation werden Sie gebeten, Ihre E-Mail-Adresse anzugeben und die untenstehende Bedingung zu akzeptieren:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): admin@example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for nextcloud.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/nextcloud-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/nextcloud-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/nextcloud-le-ssl.conf

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Geben Sie dann 2 ein und drücken Sie die Eingabetaste, um ein kostenloses SSL-Zertifikat für Ihre Domain herunterzuladen und zu installieren. Sobald die Installation erfolgreich abgeschlossen ist. Sie sollten die folgende Ausgabe erhalten:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/nextcloud.conf to ssl vhost in /etc/apache2/sites-available/
nextcloud-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://nextcloud.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=nextcloud.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
 /etc/letsencrypt/live/example.com/fullchain.pem
 Your key file has been saved at:
 /etc/letsencrypt/live/example.com/privkey.pem
 Your cert will expire on 2019-10-22. To obtain a new or tweaked
 version of this certificate in the future, simply run certbot again
 with the "certonly" option. To non-interactively renew *all* of
 your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
 configuration directory at /etc/letsencrypt. You should make a
 secure backup of this folder now. This configuration directory will
 also contain certificates and private keys obtained by Certbot so
 making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:
 Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
 Donating to EFF: https://eff.org/donate-le

Wenn Sie fertig sind, können Sie mit dem nächsten Schritt fortfahren.

Zugriff auf die NextCloud Web-Schnittstelle

Ihre NextCloud ist jetzt konfiguriert und mit Let’s Encrypt SSL gesichert. Öffnen Sie dann Ihren Webbrowser und geben Sie die URL https://nextcloud.example.com ein. Sie werden auf die folgende Seite weitergeleitet:

NextCloud-Anmeldung

Konfigurieren Sie die Datenbank

Geben Sie nun Ihren Admin-Benutzernamen und Ihr Passwort, den Datenordner und die korrekten Datenbank-Anmeldeinformationen an und klicken Sie auf die Schaltfläche Einrichtung beenden. Sie werden zum NextCloud-Dashboard auf der folgenden Seite weitergeleitet:

NextCloud Dashboard

Das war’s fürs Erste.

Schlussfolgerung

Herzlichen Glückwunsch! Sie haben NextCloud erfolgreich installiert und mit Let’s Encrypt Free SSL auf Debian 10 gesichert. Sie können jetzt Dateien, Dokumente und Medien mit anderen Benutzern über die NextCloud-Webschnittstelle problemlos gemeinsam nutzen.

Das könnte dich auch interessieren …