Nextcloud Installation Teil 1 - Webserver und DB
Zeichenerklärung
[Aktion]
<Eingabe>
!(Info)!
Verwendete User und Passwörter
Username: Admin
Passwort: Start#1234
UserDaten - Nutzdaten: /var/www/nextcloud/data
Datenbank User: nc_user
Datenbank Passwort: nc_pass
Datenbank Name: nextcloud
Datenbank Server: localhost
Vorrausetzungen
Für die Installation benötigen Sie einen Webserver mit PHP und SQL Datenbank. In dieser Installations Anleitung wird der Apache Webserver auf einem Ubuntu 26.04 mit PHP und MariaDB incl. SSL Zertifikaten für den Heimgebrauch installiert.
Eine Ausführliche Info zu den Voraussetzungen findet man auf der Webseite von Nextcloud. https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html
Webserver und DB
Basis Paktete für die Installation.
apt update
apt upgrade
apt install -y apache2 mariadb-server mariadb-client-compat openssl php php-mysql wget curl zip unzip
Überpürfen der Server Dienste
| Paket | Funktion |
|---|---|
| apache2 | Apache Hypertext Transfer Protocol Server |
| mariadb-server | the MariaDB command-line tool |
| mariadb-client-compat | Provides MySQL-compatible symlinks and tools for MariaDB |
| php | PHP Command Line Interface 'CLI' |
| php-mysql | Software bridge between PHP and SQL |
| wget | The non-interactive network downloader |
| curl | tool for transferring data from or to a server |
| zip | package and compress (archive) files |
| unzip | list, test and extract compressed files in a ZIP archive |
| openssl | OpenSSL command line tool |
MariaDB Einrichten
Interactiv über ein Script
root@nc:~# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none): <Enter Taste>
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] <n für nein> !(Erhöht die Sicherhit der Root Accounts)!
... skipping.
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] <Y>
New password: <SQL#RootPasswort>
Re-enter new password: <SQL#RootPasswort>
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] <Y>
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] <Y>
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] <Y>
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] <Y>
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
root@nc:~#
Manuel über SQL Kommandos
-- 1. Root-Authentifizierung auf das moderne Plugin umstellen (und optional ein Passwort setzen, falls gewünscht)
ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password;
-- 2. Anonyme Benutzerkonten löschen
DELETE FROM mysql.user WHERE User = '';
-- 3. Fernzugriff für den Root-Benutzer verbieten
DELETE FROM mysql.user WHERE User = 'root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
-- 4. Die unsichere Test-Datenbank entfernen
DROP DATABASE IF EXISTS test;
DELETE FROM mysql.db WHERE Db = 'test' OR Db = 'test_%';
-- 5. Berechtigungen sofort neu einlesen lassen
FLUSH PRIVILEGES;
Prüfen der Einstellungen
mariadb -u root
-- 1. Aktive Benutzer und erlaubte Hosts anzeigen
SELECT User, Host, plugin FROM mysql.user;
-- 2. Prüfen, ob die Testdatenbank noch existiert:
SHOW DATABASES LIKE 'test';
exit;
-- 3. MariaDB-Konfigurationsdateien auf dem Server ansehen
cat /etc/mysql/mariadb.conf.d/50-server.cnf
Nextcloud DB Einrichten
root@nc:~# mysql -u root
Enter password:
MariaDB [(none)]> CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> CREATE USER 'nc_user'@'localhost' IDENTIFIED BY 'nc_pass';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nc_user'@'localhost';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> exit;
Bye
root@nc:~# :
Eingaben Überprüfen
root@nc:~# mysql -u nc_user -p
Enter password:
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| nextcloud |
+--------------------+
2 rows in set (0.001 sec)
MariaDB [(none)]> exit;
Fehler behebung
mysql -u root
-- 1. Vorhandene Datenbanken auflisten
SHOW DATABASES;
-- 2. Vorhandene Benutzer auflisten:
SELECT User, Host FROM mysql.user;
-- 3. Vorherigen Versuch komplett löschen
DROP DATABASE IF EXISTS nextcloud;
DROP USER IF EXISTS 'nc_user'@'localhost';
-- 4. Alles frisch und sauber neu anlegen
CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'nc_user'@'localhost' IDENTIFIED BY 'nc_pass';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nc_user'@'localhost';
FLUSH PRIVILEGES;
Nextcloud Installieren
Download URL der Aktuellen Version https://nextcloud.com/de/install/#instructions-server
Community Projekte - Klicken Sie mit der rechten Maustaste hier und speichern Sie die Datei auf Ihrem Computer.
cd /var/www/
root@nc:# mkdir nextcloud
root@nc:# chown www-data:www-data nextcloud/
root@nc:# cd nextclou
root@nc:# wget https://download.nextcloud.com/server/installer/setup-nextcloud.php
root@nc:# chown www-data:www-data setup-nextcloud.php
Apache Webserver anpassen
Inahlt löschen und durch disen ersetzen.
vim /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/nextcloud
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Webserver neu starten
Fehlermeldung nach der Installation
Aufrufen der URL über die IP Adresse des Webservers. Beispiel: http://192.168.178.xxx für die weitere Einrichtung.
Es können folgende fehlende Pakete angezeigt werden. Die Fehler Paket Namen beziehen sich auf die PHP Unterstüzung.
Installation der fehlenden Pakete.
Eine mögliche vorgehensweise um heruszufinden welche Pakete fehlen.
root@nc:~# apt search php | grep -i zip
oder
apt install -y apt-file
apt-file update
apt-file search php | grep zip
php-zip: /usr/share/doc/php-zip/changelog.gz
php-zip: /usr/share/doc/php-zip/copyright
php8.5-zip: /usr/lib/php/20250925/zip.so
php8.5-zip: /usr/share/bug/php8.5-zip/control
php8.5-zip: /usr/share/bug/php8.5-zip/script
php8.5-zip: /usr/share/doc/php8.5-zip
php8.5-zip: /usr/share/lintian/overrides/php8.5-zip
php8.5-zip: /usr/share/php8.5-zip/zip/zip.ini
apt install php-zip
Anzeige der geladenen Apache Module
root@nc:~# apachectl -t -D DUMP_MODULES
Loaded Modules:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
systemd_module (static)
access_compat_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
filter_module (shared)
mime_module (shared)
mpm_prefork_module (shared)
negotiation_module (shared)
php_module (shared)
reqtimeout_module (shared)
setenvif_module (shared)
status_module (shared)
| NC | apt install |
|---|---|
| PHP-Modul zip | apt install php-zip |
| PHP-Modul dom PHP-Modul XMLWriter PHP-Modul libxml |
apt install php-xml |
| PHP-Modul mb (mbstring) multibyte | apt install php-mbstring |
| PHP-Modul GD | apt install php-gd |
| PHP-Modul cURL | apt install php-curl |
Installation der Fehlenden Pakete auf einmal
Danach den Webserver neu starten systemctl restart apache2
URL IP des Webserver aufrufen z.B. 192.168.178.xxx um den Admin User einzurichten.
Der Installations Assistent Fragt nach dem Installations Verzeichnis - Neu Erstellen: nextcloud. - Im Momentanen: dann nur einen . eingeben.
Anmeldung im Webbrowser
Username: Admin
Passwort: Start#1234
UserDaten - Nutzdaten: /var/www/nextcloud/data
Datenbank User: nc_user
Datenbank Passwort: nc_pass
Datenbank Name: nextcloud
Datenbank Server: localhost
Die Nextcloud ist soweit Eingerichtet.