Nextcloud

Nextcloud is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. Nextcloud is a fork of ownCloud with enterprise features included.
= Installation =
 is available in Alpine 3.5 and greater.
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an 'http' repository in your file, then:
== Database ==
First you have to decide which database to use. Use one of the databases listed below.
=== Sqlite ===
All you need to do is to install the package:
=== PostgreSQL ===
Install the package:
Next thing is to configure and start the database:
Next, you need to create a user and temporarily grant the CREATEDB privilege:
Set postgresql to start on boot/:
=== MariaDB ===
Install the package:
Now configure and start :
Follow the wizard to setup passwords, etc.
Next, you need to create a user and database and set permissions:
 is not needed anymore. Let's uninstall it:
== Webserver ==
Next thing is to choose, install, and configure a webserver. In this example we will install or . You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.
 facilitates running the webserver with php-fpm.
=== Nginx ===
Install the needed packages:
Delete the default nginx website configuration:
Create a configuration file for your site in :
If you plan to enable uploads - and you probably do) - then you need to modify the default:
client_max_body_size 1m;'
setting in . For testing purposes, I disabled the limit by changing it to:
client_max_body_size 0;
This enabled large file uploads and auto-uploads to work. Note, this is a file-size restriction in addition to the restriction set in . That second restriction defaults to:
; Maximal size of a file that can be uploaded via web interface.
php_admin_value[memory_limit] = 512M
php_admin_value[post_max_size] = 513M
php_admin_value[upload_max_filesize] = 513M
Another setting that may limit file-size is in configuration file , where I set the restriction to to:
upload_max_filesize = 513M
to match the file-size restriction.
If you are running from RAM and you're dealing with large files you might need to move the FastCGI temp file from to or to a directory that is mounted on hdd:
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:
fastcgi_read_timeout 300s;
 should already be configured to load your site config from this directory:
...
# Includes virtual hosts configs.
include /etc/nginx/http.d/*;
...
Start services:
Enable automatic startup of services:
=== Lighttpd ===
Install the package:
Make sure you have FastCGI enabled in :
Start up the webserver:
Link installation to web server directory:
== Firewall ==
Next up, open the desired port for the webserver in the firewall. You can use the following snippet as a reference for an nftable rule in a new file:
== Other settings ==
=== Hardening ===
Consider updating the variable url.access-deny in for additional security. Add "config.php" to the variable (that's where the database is stored) so it looks something like this:
Restart to activate the changes:
=== Additional packages ===
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:
You can also install the meta-package which installs all 30 core Nextcloud apps (listed as dependencies under aforementioned link):
=== How To Create a Self-Signed SSL Certificate ===
Install openssl:
Generate your self signed certificate and its private key:
Edit your nginx configuration:
=== How To Install and Set Up Auto-Renewing LetsEncrypt SSL Certificate ===
After first setting up the Nextcloud server using the instructions in the 'Configure and use Nextcloud' section below, I then followed the SSL-setup instructions at: [Tech Jogging].
I also had to add my Nextcloud servers Fully Qualified Domain Name (FQDN) to the list of trusted domains in /etc/nextcloud/config.php. In the section labelled: 'trusted_domains':
'trusted_domains' =>
 array (
 0 => '<machine's local IP address>',
 1 => 'nextcloud.mydomain.com',
 ),
}}
= Configure and use Nextcloud =
== Configure ==
Point your browser at https://mysite.mydomain.com and follow the on-screen instructions to complete the installation, supplying the database user and password created before.
== Hardening PostgreSQL ==
If you have chosen PGSQL backend, revoke CREATEDB privilege from 'mycloud' user:
== Increase upload size ==
 has overridden default file sizes, but they can be modified further to suit your needs:
; Maximal size of a file that can be uploaded via web interface.
php_admin_value[memory_limit] = 512M
php_admin_value[post_max_size] = 513M
php_admin_value[upload_max_filesize] = 513M
== Enable opcache for nginx/php81 ==
To increase performace install
Now uncomment/edit lines in /etc/php81/php.ini:
...
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128 //you can reduce this slightly when short on RAM
opcache.save_comments=1
opcache.revalidate_freq=1
...
Restart php-fpm81
== Enable thumbnail for video ==
To be able to generate thumbnails for videos, besides configuring nextcloud, you will need to unlist proc_open from php's disabled functions. PHP relies on that function to call ffmpeg to generate the thumbnails, without that it will fail to do so even if you have it enabled on config.php.
Remove proc_open from the disabled function in :
; Disable certain functions for security reasons.
; http://php.net/disable-functions
php_admin_value[disable_functions] = exec,passthru,shell_exec,system,curl_multi_exec,show_source
Now add 'OC\\Preview\\Movie' to the list of 'enabledPreviewProviders' and have ffmpeg installed:
After restarting the fpm service it should start generating thumbnails for videos.
== Clients ==
There are clients available for many platforms, Android included:
* https://nextcloud.org/sync-clients/ (nextcloud Sync clients)
* https://nextcloud.com/install/ (Android client)
 is currently available in the community repo.
= Video Communication =
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a WebRTC app, which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the Apache config instructions nextcloud.com):
Put the following config in the server section of Nginx:
# Spreed WebRTC
location ^~ /webrtc {
 proxy_pass http://127.0.0.1:8080;
 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection $connection_upgrade;
 proxy_set_header X-Forwarded-Proto $scheme;
 proxy_set_header Host $http_host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_buffering on;
 proxy_ignore_client_abort off;
 proxy_redirect off;
 proxy_connect_timeout 90;
 proxy_send_timeout 90;
 proxy_read_timeout 90;
 proxy_buffer_size 4k;
 proxy_buffers 4 32k;
 proxy_busy_buffers_size 64k;
 proxy_temp_file_write_size 64k;
 proxy_next_upstream error timeout invalid_header http_502 http_503 http_504;
}
Put the following section in the http section of Nginx:
map $http_upgrade $connection_upgrade {
 default upgrade;
 close;
}
Reload Nginx:
Install Spreed WedRTC server (make sure you have the testing repository enabled):
Using the configuration file in /etc/spreed-webrtc/spreed-webrtc-server.conf follow the instructions at nextcloud.com to configure Spreed WebRTC server. Then start the server:
Install the Spreed video calls app in Nextcloud and enjoy your private video calls.
= Nextcloud CLI occ =
Access to nextcloud's CLI tool occ:
= Upgrading =
If you're using alpine stable, rather than edge, be aware when an upgrade skips a major release version: Nextcloud doesn't support skipping a major release version in its upgrade path. For this reason, alpine also packages the previous nextcloud release as a separate package.
== See also ==
* Nextcloud - Archwiki
Category:Server