NextCloud: Difference between revisions

From FlowerHouseWiki
No edit summary
No edit summary
 
(82 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{ContainerInfo
{{ContainerInfo
|title = NextCloud-LXC
|image = Nextcloud.png
|Domain = [https://cloud.flowerhouse.at cloud.flowerhouse.at]
|Domain = [https://cloud.flowerhouse.at cloud.flowerhouse.at]
|IP = 192.168.88.10
|IP = 192.168.88.9
|MAC = 35
|MAC = B2:62:86:48:66:66
|Privileged = Yes
|Privileged = Yes
|OS = Debian Bullseye
|RAM = 1024MB
|Cores = 2
|Files = [[config.php]]<br>[[reverse-proxy.conf]]
}}
}}


<p>The NextCloud-LXC is reachable under <syntaxhighlight lang="Bash" inline>192.168.88.10</syntaxhighlight> which is located in the ServerVLAN.</p>
<p>The NextCloud-LXC is reachable under <syntaxhighlight lang="Bash" inline>192.168.88.9</syntaxhighlight> which is located in the ServerVLAN.</p>
<p>The subdomain is [https://cloud.flowerhouse.at cloud.flowerhouse.at] which is handled by the [[ReverseProxy]].</p>
<p>The subdomain is [https://cloud.flowerhouse.at cloud.flowerhouse.at] which is handled by the [[ReverseProxy]].</p>
 
<p>Check NextCloud security [https://scan.nextcloud.com/ here].</p>
__TOC__
== Basic Setup ==
== Basic Setup ==
=== NextCloud ===
=== Apache, MariaDB and PHP ===
<p>For the NextCloud installation to work in an Container, it must be privileged, otherwise it is impossible to mount an external storage</p>
<p>For the NextCloud installation to work in an Container, it must be privileged, otherwise it is impossible to mount an external storage</p>
//----- CLEAN NEXTCLOUD INSTALLATION -----
<p>NextCloud runs on Apache2 and uses MariaDB, so following packages have to be installed:</p>
<syntaxhighlight lang="console">
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 php-intl wget unzip
</syntaxhighlight>
<p>''php.ini'' has to be edited for recommended settings:</p>
<syntaxhighlight lang="console">
nano /etc/php/7.3/apache2/php.ini
</syntaxhighlight>
 
<p>Change the following settings:</p>
<syntaxhighlight lang="console">
memory_limit = 1024M
upload_max_filesize = 1000M
post_max_size = 1000M
; 3600s = 1h
max_execution_time = 3600
date.timezone = Europe/Berlin
</syntaxhighlight>
 
<p>Start and enable all services:</p>
<syntaxhighlight lang="console" line>
systemctl start apache2
systemctl start mariadb
systemctl enable apache2
systemctl enable mariadb
</syntaxhighlight>
 
=== Configure Database ===
<p>Make secure:</p>
<syntaxhighlight lang="console">
mysql_secure_installation
</syntaxhighlight>
 
<p>Create database and user for NextCloud and use random generated password:</p>
<syntaxhighlight lang="console" line>
mysql -u root -p
CREATE DATABASE nextclouddb;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'RNGPASSWORD';
GRANT ALL ON nextclouddb.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
</syntaxhighlight>
 
=== Download NextCloud ===
<p>Download [https://nextcloud.com/de/install/#instructions-server latest] NextCloud-Version:</p>
<syntaxhighlight lang="console" line>
cd /var/www
wget https://download.nextcloud.com/server/releases/nextcloud-20.0.7.zip
unzip nextcloud-20.0.7.zip
rm nextcloud-20.0.7.zip
rm -r html
</syntaxhighlight>
 
=== Configure Apache ===
<p>Create an Apache virtual host configuration file:</p>
<syntaxhighlight lang="console">
nano /etc/apache2/sites-available/nextcloud.conf
</syntaxhighlight>
 
<p>Add the following lines:</p>
<syntaxhighlight lang="apache" line>
<VirtualHost *:80>
    ServerAdmin admin@localhost
    DocumentRoot /var/www/nextcloud/
    ServerName cloud.flowerhouse.at
 
    <Directory /var/www/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/nextcloud
        SetEnv HTTP_HOME /var/www/nextcloud
    </Directory>
 
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


</VirtualHost>
</syntaxhighlight>


//installation-path: /var/www/nextcloud
<p>Enable the Apache virtual host file and other required modules:</p>
//data-Path:          /home/data
<syntaxhighlight lang="console" line>
a2ensite nextcloud.conf
a2enmod rewrite
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime
</syntaxhighlight>


//Install missing php-package
<p>Restart apache service:</p>
apt install php-intl
<syntaxhighlight lang="console">
systemctl restart apache2
</syntaxhighlight>


//Add trusted domain
=== Trusted Domains ===
<p>Add trusted domain:</p>
<syntaxhighlight lang="console">
nano /var/www/nextcloud/config/config.php
nano /var/www/nextcloud/config/config.php
</syntaxhighlight>


//Zur Datei hinzufügen
<p>Add to file:</p>
<syntaxhighlight lang="php" line>
'trusted_domains' =>
'trusted_domains' =>
   array (
   array (
Line 31: Line 129:
     1 => 'cloud.flowerhouse.at',
     1 => 'cloud.flowerhouse.at',
   ),
   ),
</syntaxhighlight>


//Neu laden
<p>Restart apache service:</p>
<syntaxhighlight lang="console">
systemctl restart apache2
systemctl restart apache2
</syntaxhighlight>
=== NFS-Share ===
<p>Install required packages for nfs-share:</p>
<syntaxhighlight lang="console">
apt install nfs-common nfs4-acl-tools
</syntaxhighlight>


//Bug-FIX
<p>Mount the nfs-share (NAS) to the data folder where all the user files will be stored</p>
https://github.com/nextcloud/server/pull/23606/files
<syntaxhighlight lang="console">
mount -t nfs 192.168.88.5:/mnt/zpool1/NextCloud /home/data/
</syntaxhighlight>


//----- ADD NFS SHARE -----
<p>Edit fstab to mount at boot:</p>
//Install packages
<syntaxhighlight lang="console">
apt install nfs-common
nano /etc/fstab
apt install nfs4-acl-tools
</syntaxhighlight>


//Mount share to folder
<p>Add following line at the end of file:</p>
https://linuxhint.com/mount_nfs_share_debian/
<syntaxhighlight lang="console">
mount -t nfs 192.168.88.5:/mnt/zpool1/NextCloud /home/data/
192.168.88.5:/mnt/zpool1/NextCloud /home/data/ nfs defaults 0 0
192.168.88.5:/mnt/zpool1/NextCloud /home/data/ nfs defaults 0 0
</syntaxhighlight>


U4v3kraALVSTEyTQ
<p>Re-scan all files after mounting to update file database
//ReScan all files after mounting:
<syntaxhighlight lang="console">
sudo -u www-data php /var/www/nextcloud/occ files:scan --all
sudo -u www-data php /var/www/nextcloud/occ files:scan --all
</syntaxhighlight>
=== Web Interface ===
<p>After setting up the [[Reverse-Proxy]] you can access the web interface and make the last configurations</p>
<p>Add admin account and the data folder path <syntaxhighlight lang="Bash" inline>/home/data/</syntaxhighlight>.</p>
<p>At last add your database credentials and finish setup:</p>
* User: nextclouduser
* PW: RNGPASSWORD
* Database: nextclouddb
* Host: localhost
=== Update ===
<p>Use following command to update nextcloud to latest version:</p>
<syntaxhighlight lang="console">
sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/updater/updater.phar
</syntaxhighlight>
=== Maintenance Mode ===
<p>Use following command to disable maintenance mode:</p>
<syntaxhighlight lang="console">
sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/occ maintenance:mode --off
</syntaxhighlight>
== Additional Configuration ==
<p>When NextCloud is running, it is recommended to look under ''Settings->Overview'' if there are some errors and warnings listed and fix them.</p>
<p>Following are some fixes to already occured problems.</p>
=== Looping Connection Wizard ===
<p>When using an [[Reverse-Proxy]] the Connection Wizard is looping between "login" and "grant access".</p>
<p>The solution is to edit the NextCloud ''config.php'':</p>
<syntaxhighlight lang="console">
nano /var/www/nextcloud/config/config.php
</syntaxhighlight>
<p>Add the following line to the config array:</p>
<syntaxhighlight lang="php">
'overwriteprotocol' => 'https',
</syntaxhighlight>
=== PHP-Memory-Cache ===
<p>Install a local memory caching backend:</p>
<syntaxhighlight lang="console" line>
apt-get install php-apcu
service apache2 restart
</syntaxhighlight>
<p>Edit the NextCloud config.php:</p>
<syntaxhighlight lang="console">
nano /var/www/nextcloud/config/config.php
</syntaxhighlight>
<p>Add the following line to the config array:</p>
<syntaxhighlight lang="php">
'memcache.local' => '\OC\Memcache\APCu',
</syntaxhighlight>
=== Max. Upload-Size ===
==== NextCloud ====
<p>Edit ''php.ini'':</p>
<syntaxhighlight lang="console">
nano /etc/php/7.3/apache2/php.ini
</syntaxhighlight>
<p>Change the following settings:</p>
<syntaxhighlight lang="console">
memory_limit = 1024M
upload_max_filesize = 1000M
post_max_size = 1000M
</syntaxhighlight>
==== Reverse-Proxy ====
<p>Edit ''nginx.conf'':</p>
<syntaxhighlight lang="console">
nano /etc/nginx/nginx.conf
</syntaxhighlight>
<p>Change following line to:</p>
<syntaxhighlight lang="nginx">
client_max_body_size 1000M;
</syntaxhighlight>
<p>Reload [[Reverse-Proxy]] configuration:</p>
<syntaxhighlight lang="console">
nginx -s reload
</syntaxhighlight>
<p>In the [[reverse-proxy.conf]] following entry must also be adjusted:</p>
<syntaxhighlight lang="nginx">
client_max_body_size 1000M;
</syntaxhighlight>


//UPLOAD SIZE
=== DataBase ===
client_max_body_size 100M; in reverse-proxy.conf und nginx.conf wichtig. MaxFileSize = Useable RAM
==== Missing Indizes ====
https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/web/nginx.conf#L76
<p>If the database is missing indizes run:</p>
<syntaxhighlight lang="console" line>
service apache2 stop
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices
service apache2 start
</syntaxhighlight>


//NextCloud Reverse Proxy config
==== Convert to 'big int' ====
https://help.nextcloud.com/t/connection-wizard-is-looping-between-log-in-and-grant-access/46809/4
<p>If a warning says that some tables should be converted to 'big int' run:</p>
<syntaxhighlight lang="console" line>
service apache2 stop
sudo -u www-data php /var/www/nextcloud/occ db:convert-filecache-bigint
service apache2 start
</syntaxhighlight>


//Import external storage
=== External Storage ===
https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/external_storage_configuration_gui.html
https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/external_storage_configuration_gui.html


== Sources ==
== Sources ==
* [https://www.howtoforge.com/tutorial/how-to-install-nextcloud-on-debian-10/ NextCloud on Debian]+
* [https://www.howtoforge.com/tutorial/how-to-install-nextcloud-on-debian-10/ NextCloud on Debian]
* [https://www.youtube.com/watch?v=QB_FEWJ9BB4 Nextcloud Installation auf Ubuntu 20.04 Server]
* [https://www.youtube.com/watch?v=QB_FEWJ9BB4 Nextcloud Installation auf Ubuntu 20.04 Server]
* [https://github.com/nextcloud/server/pull/23606/files Bug-Fix]
* [https://linuxhint.com/mount_nfs_share_debian/ nfs-share]
* [https://help.nextcloud.com/t/connection-wizard-is-looping-between-log-in-and-grant-access/46809/4 Looping Connection Wizard]

Latest revision as of 20:31, 16 December 2021

Nextcloud.png

Network


IP: 192.168.88.9
MAC: B2:62:86:48:66:66
Domain: cloud.flowerhouse.at

System


OS: Debian Bullseye
Files: config.php
reverse-proxy.conf
RAM: 1024MB
Cores: 2
Privileged: Yes

The NextCloud-LXC is reachable under 192.168.88.9 which is located in the ServerVLAN.

The subdomain is cloud.flowerhouse.at which is handled by the ReverseProxy.

Check NextCloud security here.

Basic Setup

Apache, MariaDB and PHP

For the NextCloud installation to work in an Container, it must be privileged, otherwise it is impossible to mount an external storage

NextCloud runs on Apache2 and uses MariaDB, so following packages have to be installed:

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 php-intl wget unzip

php.ini has to be edited for recommended settings:

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

Change the following settings:

memory_limit = 1024M
upload_max_filesize = 1000M
post_max_size = 1000M
; 3600s = 1h
max_execution_time = 3600
date.timezone = Europe/Berlin

Start and enable all services:

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

Configure Database

Make secure:

mysql_secure_installation

Create database and user for NextCloud and use random generated password:

mysql -u root -p
CREATE DATABASE nextclouddb;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'RNGPASSWORD';
GRANT ALL ON nextclouddb.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Download NextCloud

Download latest NextCloud-Version:

cd /var/www
wget https://download.nextcloud.com/server/releases/nextcloud-20.0.7.zip
unzip nextcloud-20.0.7.zip
rm nextcloud-20.0.7.zip
rm -r html

Configure Apache

Create an Apache virtual host configuration file:

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

Add the following lines:

<VirtualHost *:80>
     ServerAdmin admin@localhost
     DocumentRoot /var/www/nextcloud/
     ServerName cloud.flowerhouse.at

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

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

</VirtualHost>

Enable the Apache virtual host file and other required modules:

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

Restart apache service:

systemctl restart apache2

Trusted Domains

Add trusted domain:

nano /var/www/nextcloud/config/config.php

Add to file:

'trusted_domains' =>
  array (
    0 => '192.168.88.10',
    1 => 'cloud.flowerhouse.at',
  ),

Restart apache service:

systemctl restart apache2

NFS-Share

Install required packages for nfs-share:

apt install nfs-common nfs4-acl-tools

Mount the nfs-share (NAS) to the data folder where all the user files will be stored

mount -t nfs 192.168.88.5:/mnt/zpool1/NextCloud /home/data/

Edit fstab to mount at boot:

nano /etc/fstab

Add following line at the end of file:

192.168.88.5:/mnt/zpool1/NextCloud /home/data/ nfs defaults 0 0

Re-scan all files after mounting to update file database

sudo -u www-data php /var/www/nextcloud/occ files:scan --all

Web Interface

After setting up the Reverse-Proxy you can access the web interface and make the last configurations

Add admin account and the data folder path /home/data/.

At last add your database credentials and finish setup:

  • User: nextclouduser
  • PW: RNGPASSWORD
  • Database: nextclouddb
  • Host: localhost

Update

Use following command to update nextcloud to latest version:

sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/updater/updater.phar

Maintenance Mode

Use following command to disable maintenance mode:

sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/occ maintenance:mode --off

Additional Configuration

When NextCloud is running, it is recommended to look under Settings->Overview if there are some errors and warnings listed and fix them.

Following are some fixes to already occured problems.

Looping Connection Wizard

When using an Reverse-Proxy the Connection Wizard is looping between "login" and "grant access".

The solution is to edit the NextCloud config.php:

nano /var/www/nextcloud/config/config.php

Add the following line to the config array:

'overwriteprotocol' => 'https',

PHP-Memory-Cache

Install a local memory caching backend:

apt-get install php-apcu
service apache2 restart

Edit the NextCloud config.php:

nano /var/www/nextcloud/config/config.php

Add the following line to the config array:

'memcache.local' => '\OC\Memcache\APCu',

Max. Upload-Size

NextCloud

Edit php.ini:

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

Change the following settings:

memory_limit = 1024M
upload_max_filesize = 1000M
post_max_size = 1000M

Reverse-Proxy

Edit nginx.conf:

nano /etc/nginx/nginx.conf

Change following line to:

client_max_body_size 1000M;

Reload Reverse-Proxy configuration:

nginx -s reload

In the reverse-proxy.conf following entry must also be adjusted:

client_max_body_size 1000M;

DataBase

Missing Indizes

If the database is missing indizes run:

service apache2 stop
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices
service apache2 start

Convert to 'big int'

If a warning says that some tables should be converted to 'big int' run:

service apache2 stop
sudo -u www-data php /var/www/nextcloud/occ db:convert-filecache-bigint
service apache2 start

External Storage

https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/external_storage_configuration_gui.html

Sources