# ☁️ Nextcloud auf Debian installieren

Diese Anleitung zeigt Schritt für Schritt, wie du **Nextcloud** auf **Debian** installierst und konfigurierst.

---

## ⚙️ Voraussetzungen

Bevor du beginnst, installiere bitte die folgenden Komponenten:

- **PHP** (Version 8.x) → [!ref](php8.0.md)
- **MariaDB** Datenbank → [!ref](mariadb.md)

Apache Webserver installieren:

```bash
sudo apt install -y apache2
```

Optional: phpMyAdmin (zur Datenbankverwaltung)

> [!ref](phpmyadmin.md)

---

## 🧩 PHP-Erweiterungen installieren

Nextcloud benötigt zahlreiche PHP‑Module. Wähle unten die passende PHP‑Version.

+++ PHP 8.1
```bash
sudo apt install -y php8.1 php8.1-ctype php8.1-curl php8.1-dom php8.1-fileinfo php8.1-filter php8.1-gd php8.1-xml php8.1-mbstring php8.1-openssl php8.1-posix php8.1-session php8.1-zip php8.1-zlib php8.1-mysql php8.1-imagick imagick php8.1-gmp php8.1-bcmath
```
+++ PHP 8.2
```bash
sudo apt install -y php8.2 php8.2-ctype php8.2-curl php8.2-dom php8.2-fileinfo php8.2-filter php8.2-gd php8.2-xml php8.2-mbstring php8.2-openssl php8.2-posix php8.2-session php8.2-zip php8.2-zlib php8.2-mysql php8.2-imagick imagick php8.2-gmp php8.2-bcmath
```
+++ PHP 8.3
```bash
sudo apt install -y php8.3 php8.3-ctype php8.3-curl php8.3-dom php8.3-fileinfo php8.3-filter php8.3-gd php8.3-xml php8.3-mbstring php8.3-openssl php8.3-posix php8.3-session php8.3-zip php8.3-zlib php8.3-mysql php8.3-imagick imagick php8.3-gmp php8.3-bcmath
```
+++

Danach den Webserver neu starten:

```bash
sudo systemctl restart apache2
```

---

## 📥 Nextcloud herunterladen & installieren

### 1️⃣ Installationsdatei laden

```bash
wget https://download.nextcloud.com/server/installer/setup-nextcloud.php
```

### 2️⃣ Datei verschieben
```bash
sudo mv setup-nextcloud.php /var/www/html/
```

### 3️⃣ Berechtigungen setzen
```bash
sudo chown -R www-data:www-data /var/www/html/
```

---

## 🗄️ Datenbank-Benutzer erstellen

Melde dich in MariaDB an:

```bash
sudo mysql -u root -p
```

Erstelle Benutzer & Datenbank für Nextcloud:

```sql
CREATE DATABASE nextcloud;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'deinpasswort';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
```

---

## 🌐 Webinstallation starten

Rufe im Browser auf:

```
http://<DEINE_SERVER_IP>/setup-nextcloud.php
```

Folge dem Installationsassistenten und gib dabei an:

- Datenbank: `nextcloud`
- Benutzer: `nextclouduser`
- Passwort: dein Passwort

---

## ✅ Abschluss

Nach erfolgreicher Einrichtung kannst du dich im **Nextcloud Webinterface** anmelden und Benutzer, Apps oder externe Speicher konfigurieren.
