# Nextcloud installieren

Nextcloud 27 installieren

<iframe allowfullscreen="allowfullscreen" height="314" src="https://www.youtube.com/embed/XuxUVYbOM6Y" width="560"></iframe>

#### Befehle: 

Updating

```
apt update && apt upgrade -y
```

<p class="callout info">individuelle Anpassung des Speicherplatzes</p>

```
# Fstab anpassen
nano /etc/fstab

# Daten
/dev/sdb 	/mnt/Daten 	ext4  defaults 0 2

# Datensicherung mit Borgbackup auf DS 
//192.168.1.100/pxxData/ncbackup /mnt/smb-ds cifs uid=1000,gid=1000,rw,user,credentials=/root/.smbzuga 0 0
```

Formatieren von /dev/sdb in ext4

```
mkfs.ext4 /dev/sdb1
```

Credentials

```
nano /root/.smbzuga

username=username
password=password
```

Cifs-Utils installieren

[Nextcloud VM oder VM Container mit NAS verbinden](https://wiki.hhml.selfhost.co/books/nextcloud/page/nextcloud-vm-oder-vm-container-mit-nas-verbinden "Nextcloud VM oder VM Container mit NAS verbinden")

Installing apache

```
apt install apache2
```

Install php 8.2

```
apt install software-properties-common
```

```
add-apt-repository ppa:ondrej/php
```

```
apt update
```

Install php 8.2 &amp; Moduls

```
apt install php8.2 libapache2-mod-php8.2 php8.2-zip php-dompdf php8.2-xml php8.2-mbstring php8.2-gd php8.2-curl php8.2-imagick libmagickcore-6.q16-6-extra php8.2-intl php8.2-bcmath php8.2-gmp php8.2-cli php8.2-mysql php8.2-zip php8.2-gd  php8.2-mbstring php8.2-curl php8.2-xml php-pear unzip nano php8.2-apcu redis-server ufw php8.2-redis php8.2-smbclient php8.2-ldap
```

adjust PHP.ini file

```
nano /etc/php/8.2/apache2/php.ini
```

```
memory_limit = 2048M
upload_max_filesize = 20G
post_max_size = 20G
date.timezone = Europe/Berlin
output_buffering = Off
```

Install Database Server

```
apt install mariadb-server
```

Maria DB Server Konfigurateion

```
mysql_secure_installation
```

Open SQL dialog

```
mysql
```

Create databas calles nextcloud

```
CREATE DATABASE nextcloud; 
```

Create database user with password

```
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'password_here';
```

Grant access to database

```
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
```

Save changes and exit

```
FLUSH PRIVILEGES;
```

```
EXIT;
```

Download latest nextcloud version

```
cd /tmp && wget https://download.nextcloud.com/server/releases/latest.zip
```

```
unzip latest.zip
```

```
mv nextcloud /var/www/
```

adjust apache conf

```
nano /etc/apache2/sites-available/000-default.conf
```

-&gt; change /var/www/html to /var/www/nextcloud

Enable the NextCloud and Rewrite Module

```
a2enmod rewrite
```

```
a2enmod headers
```

```
a2enmod env
```

```
a2enmod dir
```

```
a2enmod mime
```

restarat apache

```
service apache2 restart
```

prepare data folder

```
mkdir /home/data/
```

```
chown -R www-data:www-data /home/data/
```

```
chown -R www-data:www-data /var/www/nextcloud/
```

```
chmod -R 755 /var/www/nextcloud/
```

## Nextcloud am Browser Aufrufen

Über die IP-Adresse kann die Nextcloud jetzt erreicht werden.

Über **Nginx Proxy Manager** erreichbar machen

Vertrauenswürdigen server erstellen

```
cd /var/www/nextcloud
```

<details id="bkmrk-nextcloud-24-install"><summary>Nextcloud 24 installieren</summary>

Nextcloud 24 auf einem Ubuntu Server installieren

<iframe allowfullscreen="allowfullscreen" height="314" src="https://www.youtube.com/embed/8Hw7M7tcI9o" width="560"></iframe>

Bei der Installation von PHP die Befehle einzeln eingeben.

```
# updating 
apt update && apt upgrade -y

# Installing apache
apt install apache2

# Install PHP 8.1 (Diese Befehle einzeln eingeben) 
apt install software-properties-common
add-apt-repository ppa:ondrej/php
apt update

# Install PHP 8.1 & Moduls
apt install php8.1 libapache2-mod-php8.1 php8.1-zip php-dompdf php8.1-xml php8.1-mbstring php8.1-gd php8.1-curl php8.1-imagick libmagickcore-6.q16-6-extra php8.1-intl php8.1-bcmath php8.1-gmp php8.1-cli php8.1-mysql php8.1-zip php8.1-gd  php8.1-mbstring php8.1-curl php8.1-xml php-pear unzip nano php8.1-apcu redis-server ufw php8.1-redis

# adjust PHP.ini file
nano /etc/php/8.1/apache2/php.ini

memory_limit = 1024M
upload_max_filesize = 16G
post_max_size = 16G
date.timezone = Europe/Berlin
output_buffering = Off


# Install Databse Server
apt install mariadb-server

# Maria DB Server Konfiguration
mysql_secure_installation

# open SQL dialoge
mysql

# create database calles nextcloud
CREATE DATABASE nextcloud; 

# create database user with password
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'password_here';

#grant accesss to databse
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';

#save changes and exit
FLUSH PRIVILEGES;
EXIT;

# Download lastest nextcloud version
cd /tmp && wget https://download.nextcloud.com/server/releases/latest.zip
unzip latest.zip
mv nextcloud /var/www/

#edit new conf
nano /etc/apache2/sites-available/000-default.conf

DocumentRoot auf /var/www/nextcloud ändern
 
# Enable the NextCloud and Rewrite Module

a2enmod rewrite
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime

# restart apache
service apache2 restart

# prepare data folder
mkdir /home/data/
chown -R www-data:www-data /home/data/

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

## create Let's Encrypt SSL-Certificate

#install certbot
apt install certbot python3-certbot-apache

certbot --apache -m master@domain.com -d cloud.domain.com

--> Domain ansurfen und Einrichtung abschließen
```

</details>