# Nextcloud Installation Teil 1 - Webserver und DB **Zeichen Erklärung** ``` [Aktion] !(Info)! ``` ## 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 22.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](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 openssl php wget curl zip unzip ``` | Paket | Funktion | |:-------------- | -------------------------------------------------------- | | apache2 | Apache Hypertext Transfer Protocol Server | | mariadb-server | the MariaDB command-line tool | | openssl | OpenSSL command line tool | | php | PHP Command Line Interface 'CLI' | | 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 | ### MariaDB Einrichten ``` 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): 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] !(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] New password: Re-enter new password: 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] ... 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] ... 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] - 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] ... 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:~# ``` ### Nextcloud DB Einrichten ``` root@nc:~# mysql -u root -p Enter password: MariaDB [(none)]> create database nextcloud; 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' identified by 'nc_pass'; 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:~# : ``` **Testen** ``` root@nc20-0:~# 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; ``` ## Nextcloud Installieren **Download URL der Aktuellen Version** https://nextcloud.com/de/install/#instructions-server Community Projekte - Klicken Sie mit der rechten Maustaste [hier](https://download.nextcloud.com/server/installer/setup-nextcloud.php) 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:# weget https://download.nextcloud.com/server/installer/setup-nextcloud.php root@nc:# chown www-data:www-data setup-nextcloud.php ``` ### Apache Webserver anpassen ``` cd /etc/apache2/sites-available/ Alle Kommentar Zeilen können Entfernt werde. vim /etc/apache2/sites-enabled/000-default.conf ServerAdmin webmaster@localhost DocumentRoot /var/www/nextcloud ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # vim: syntax=apache ts=4 sw=4 sts=4 sr noet ``` **Webserver neu starten** ``` systectl restart apache2 ``` ### 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. ``` - zip - dom - XMLWriter - libxml - mb multibyte - GD - SimpleXML - curl ``` ### Installation der fehlenden Pakete. Eine mögliche vorgehensweise um heruszufinden welche Pakete fehlen. ``` root@nc:~# apt search php | grep -i zip WARNING: apt does not have a stable CLI interface. Use with caution in scripts. bzip2 module for PHP [default] php-pclzip/jammy 2.8.2-5 all php-zip/jammy 2:8.1+92ubuntu1 all !(Tip: Nach Möglichket Paket Namen ohne spezielle Versions Nr. verwenden.)! bzip2 module for PHP php8.1-zip/jammy-updates,jammy-security 8.1.2-1ubuntu2.14 amd64 ``` **Anzeige der geladenen Apache Module** ``` root@nc:~# apachectl -t -D DUMP_MODULES root@nc:~# man apachectl root@nc:~# apachectl -t -D DUMP_MODULES AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message 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) 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 | |:------------------- | ------------------------------ | | MySQL Module | apt install php-mysql | | PHP-Modul zip | apt install php-zip | | PHP-Modul dom | apt install libapache2-mod-php | | PHP-Modul XMLWriter | apt install php-xml | | PHP-Modul mbstring | apt install php-mbstring | | PHP-Modul GD | apt install php-gd | | PHP-Modul cURL | apt install php-curl | **Installation der Fehlenden Pakete auf einmal** ``` apt install php-mysql php-zip libapache2-mod-php php-xml php-mbstring php-gd php-curl ``` 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. ``` 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.