This repository has been archived on 2023-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
wiki/howto/nextcloud.md

397 lines
14 KiB
Markdown
Raw Permalink Normal View History

2020-02-17 14:05:39 +01:00
<!-- START doctoc.sh generated TOC please keep comment here to allow auto update -->
<!-- DO NOT EDIT THIS SECTION, INSTEAD RE-RUN doctoc.sh TO UPDATE -->
**Table of Contents**
- [installation guides](#installation-guides)
- [install nextcloud in debian9, apache, mysql](#install-nextcloud-in-debian9-apache-mysql)
- [install nextcloud in debian10, nginx and postgresql](#install-nextcloud-in-debian10-nginx-and-postgresql)
- [migrate from mysql or sqlite to postgresql](#migrate-from-mysql-or-sqlite-to-postgresql)
- [calendar and reminders](#calendar-and-reminders)
2020-02-17 14:05:39 +01:00
- [collabora online](#collabora-online)
- [issue related to docker and xfs malfunction](#issue-related-to-docker-and-xfs-malfunction)
- [install cache system for nextcloud](#install-cache-system-for-nextcloud)
- [run occ operations](#run-occ-operations)
- [extra references](#extra-references)
<!-- END doctoc.sh generated TOC please keep comment here to allow auto update -->
# installation guides
## install nextcloud in debian9, apache, mysql
2019-03-15 04:06:10 +01:00
install apache
apt-get install apache2 libapache2-mod-php7.0
install mysql
apt-get install mariadb-server php7.0-mysql
install php
apt-get install php7.0-gd php7.0-json php7.0-curl php7.0-mbstring
install php extensions
apt-get install php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip
install apache modules
a2enmod php7.0 rewrite headers env dir mime
2020-03-10 15:18:07 +01:00
download latest nextcloud compatible with php7.0 (debian9)
2019-03-15 04:06:10 +01:00
cd /var/www/html
2020-03-10 15:18:07 +01:00
wget -c https://download.nextcloud.com/server/releases/nextcloud-15.0.14.zip
unzip -qq nextcloud-*.zip
2019-03-15 04:06:10 +01:00
chown -R www-data: nextcloud
do apache configuration for nextcloud
vi /etc/apache2/sites-available/nextcloud.conf
2019-03-15 04:14:43 +01:00
option /nextcloud - use this configuration if you want to access nextcloud through example.com/nextcloud - put in file `/etc/apache2/conf-available/nextcloud.conf`:
2019-03-15 04:06:10 +01:00
```
2020-03-10 15:18:07 +01:00
Alias /nextcloud "/var/www/html/nextcloud/"
2019-03-15 04:06:10 +01:00
2020-03-10 15:18:07 +01:00
<Directory /var/www/html/nextcloud/>
2019-03-15 04:06:10 +01:00
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
2020-03-10 15:18:07 +01:00
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
2019-03-15 04:06:10 +01:00
</Directory>
```
2019-03-15 04:14:43 +01:00
enable config
a2enconf nextcloud.conf
option nextcloud.example.com - in case you use a subdomain like nextcloud.example.com - put in file `/etc/apache2/sites-available/nextcloud.example.com.conf`:
2019-03-15 04:06:10 +01:00
```
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
DocumentRoot /var/www/html/nextcloud
ServerName nextcloud.example.com
2020-03-10 15:18:07 +01:00
<Directory /var/www/html/nextcloud/>
2019-03-15 04:06:10 +01:00
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
2020-03-10 15:18:07 +01:00
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
2019-03-15 04:06:10 +01:00
Satisfy Any
</Directory>
<Directory "/var/www/html/nextcloud/data/">
# just in case if .htaccess gets disabled
Require all denied
</Directory>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15768000; preload"
</IfModule>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
2020-03-12 21:27:57 +01:00
# add rewrites suggested by https://docs.nextcloud.com/server/stable/admin_manual/issues/general_troubleshooting.html#service-discovery
2019-03-19 21:37:07 +01:00
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/\.well-known/host-meta https://nextcloud.example.com/public.php?service=host-meta [QSA,L]
RewriteRule ^/\.well-known/host-meta\.json https://nextcloud.example.com/public.php?service=host-meta-json [QSA,L]
RewriteRule ^/\.well-known/webfinger https://nextcloud.example.com/public.php?service=webfinger [QSA,L]
RewriteRule ^/\.well-known/carddav https://nextcloud.example.com/remote.php/dav/ [R=301,L]
RewriteRule ^/\.well-known/caldav https://nextcloud.example.com/remote.php/dav/ [R=301,L]
</IfModule>
2019-03-15 04:06:10 +01:00
</VirtualHost>
</IfModule>
```
enable site for apache
2019-03-15 04:14:43 +01:00
a2ensite nextcloud.example.com.conf
2019-03-15 04:06:10 +01:00
add in `/etc/php/7.0/apache2/php.ini`:
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
2019-03-19 20:56:05 +01:00
replace `memory_limit` in `/etc/php/7.0/apache2/php.ini` to be:
memory_limit = 512M
2020-07-15 00:09:28 +02:00
go to `/etc/php/7.2/fpm/pool.d` and uncomment `env[PATH] = /usr/local/bin:/usr/bin:/bin` (thanks https://wiki.turris.cz/doc/en/public/nextcloud_security_setup)
2019-03-15 04:06:10 +01:00
[optional] in case you want to have data in different disk/storage:
mkdir -p /media/data/nextcloud
chown -R www-data: /media/data/nextcloud
cd /var/www/html/nextcloud
mv data /media/data/nextcloud
ln -s /media/data/nextcloud/data data
create user, database and choose privileges for nextcloud's case: run `mysql_setpermission` and select option 6
run in browser nextcloud and follow steps to install it
enter nextcloud, go to apps and install: calendar, polls, collabora online
## install nextcloud in debian10, nginx and postgresql
2020-02-17 14:05:39 +01:00
install following dependencies:
apt install php7.3-fpm php7.3-pgsql postgresql-11 php7.3-gd php7.3-json php7.3-curl php7.3-mbstring php7.3-intl php-imagick php7.3-xml php7.3-zip
prepare postgresql
2020-02-17 14:05:39 +01:00
2020-04-17 15:46:09 +02:00
su - postgres -c psql
CREATE USER nextcloud with encrypted password 'nextcloud';
CREATE DATABASE nextcloud encoding 'UTF8' owner nextcloud;
exit
2020-02-17 14:05:39 +01:00
prepare location
cd /var/www/html
wget -c https://download.nextcloud.com/server/releases/nextcloud-18.0.1.zip
2020-03-10 15:18:07 +01:00
unzip -qq nextcloud-*.zip
2020-02-17 14:05:39 +01:00
chown -R www-data: nextcloud
2020-07-15 00:09:28 +02:00
follow [this guide]( https://docs.nextcloud.com/server/table/admin_manual/installation/nginx.html#nextcloud-in-the-webroot-of-nginx), in my case I did the following change on top
2020-02-17 14:05:39 +01:00
```
2020-07-15 00:09:28 +02:00
# thanks https://docs.nextcloud.com/server/stable/admin_manual/installation/nginx.html#nextcloud-in-the-webroot-of-nginx
2020-02-17 14:05:39 +01:00
upstream php-handler {
#server 127.0.0.1:9000;
#server unix:/var/run/php/php7.2-fpm.sock;
#
2020-03-10 15:18:07 +01:00
# did
# php-fpm7.3
2020-02-17 14:05:39 +01:00
# said
# [17-Feb-2020 13:18:14] ERROR: Another FPM instance seems to already listen on /run/php/php7.3-fpm.sock
server unix:/run/php/php7.3-fpm.sock;
}
```
2020-03-10 15:18:07 +01:00
https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#php-fpm-tips-label
2020-07-27 17:56:36 +02:00
- A warning says that php is not properly configured. In `/etc/php/7.3/fpm/pool.d/www.conf` uncomment line `env[PATH] = /usr/local/bin:/usr/bin:/bin` . Extra source: https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#php-fpm-tips-label
- A warning suggests increasing the memory limit for php. In `/etc/php/7.3/fpm/php.ini` replace line `memory_limit = 128M` with `memory_limit = 512M`
- A warning suggests to index something (expensive on large deployments) `su www-data -s /bin/sh -c "php /var/www/html/nextcloud/occ db:add-missing-indices"`
2020-03-10 15:18:07 +01:00
- A warning suggests to convert something (expensive on large deployments) `su www-data -s /bin/sh -c "php /var/www/html/nextcloud/occ db:convert-filecache-bigint"`
- A warning suggests to adapt http headers (add this in nginx server or general nginx.conf) and reload nginx:
2020-07-27 17:56:36 +02:00
after all of that: `systemctl restart php7.3-fpm.service` (maybe restart nginx too)
```
add_header X-Frame-Options SAMEORIGIN;
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
```
# migrate from mysql or sqlite to postgresql
adapt the following environment to your needs and execute:
username="nextcloud"
2020-03-10 15:18:07 +01:00
hostname="localhost"
dbname="nextcloud"
dbpass="nextcloud"
su www-data -s /bin/sh -c "php /var/www/html/nextcloud/occ db:convert-type --all-apps --port 5432 --password $dbpass pgsql $username $hostname $dbname --no-interaction"
after executing that script the database is automatically moved in the nextcloud configuration from dbtype `mysql` to `pgsql`, etc.
2020-03-10 15:17:50 +01:00
extra source https://docs.nextcloud.com/server/stable/admin_manual/configuration_database/db_conversion.html
# calendar and reminders
enable calendar app
activate cronjob: settings / basic settings / background jobs: select Cron
in a terminal, do `crontab -u www-data -e` and add the following line
*/5 * * * * php -f /var/www/html/nextcloud/cron.php
src https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/background_jobs_configuration.html
2020-03-02 22:21:48 +01:00
2019-03-15 04:06:10 +01:00
# collabora online
install docker
```
2020-03-10 15:18:07 +01:00
apt-get install \
2019-03-15 04:06:10 +01:00
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
2020-03-10 15:18:07 +01:00
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
2019-03-15 04:06:10 +01:00
apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io
after that you have to reboot https://github.com/docker/for-linux/issues/598
2020-07-27 17:56:36 +02:00
source https://docs.docker.com/install/linux/docker-ce/debian/ or
[apache reverse proxy option](https://www.collaboraoffice.com/code/apache-reverse-proxy/)
[nginx reverse proxy option](https://www.collaboraoffice.com/code/nginx-reverse-proxy/)
2019-03-15 04:06:10 +01:00
2020-07-27 17:56:36 +02:00
I had to add this entry, which helped nextcloud to detect the collaboraonline thing (?)
2019-03-15 04:06:10 +01:00
```
2020-07-27 17:56:36 +02:00
location / {
proxy_pass https://127.0.0.1:9980;
proxy_set_header Host $http_host;
}
2019-03-15 04:06:10 +01:00
```
2020-07-27 17:56:36 +02:00
because we are using spanish and english dictionaries, we have to install them according to [this source](https://github.com/husisusi/officeonlin-install.sh/issues/155#issuecomment-457002079)
2019-03-15 04:06:10 +01:00
2020-07-27 17:56:36 +02:00
apt install hunspell locales-all hunspell-en-us hunspell-es
2019-03-15 04:06:10 +01:00
2019-03-15 04:14:43 +01:00
if your reverse proxy is in localhost (or change 127.0.0.1 to the interface you can securely listen)
2019-03-15 04:06:10 +01:00
this also serves as an script to upgrade docker, change the target_tag and be careful with the space it fills in your system
```
# src https://hub.docker.com/r/collabora/code/tags
2020-07-15 00:09:28 +02:00
# tag: last time checked 2020-7-15
target_tag="4.2.5.3"
nextcloud_domain="nextcloud.example.com" # or example.com if is a subdomain
2020-07-15 00:09:28 +02:00
# this is not needed
#nextcloud_domain="$(echo $nextcloud_domain | sed 's/\./\\\\\./g')"
docker run -t -d -p 127.0.0.1:9980:9980 -e "domain=$nextcloud_domain" -e 'dictionaries=en es ..' --restart always --cap-add MKNOD collabora/code:$target_tag
```
2019-03-15 04:06:10 +01:00
if you have firewall:
- ACCEPT traffic for docker0 bridge interface
- don't allow docker to modify firewall, put `DOCKER_OPTS="--iptables=false"` in `/etc/default/docker`
a way to validate that collabora online is working:
2020-07-27 17:56:36 +02:00
https://office.example.com/hosting/capabilities
extra links to check that it is working ([thanks](https://www.allerstorfer.at/nextcloud-install-collabora-online/)):
- https://office.example.com/hosting/discovery
- https://office.example.com/loleaflet/dist/admin/admin.html
2019-03-15 04:06:10 +01:00
2020-07-27 17:56:36 +02:00
extra link about how to compile and install yourself (docker contains a limitation of less than 60 persons in the same document) https://github.com/husisusi/officeonlin-install.sh
2019-03-28 01:05:35 +01:00
2019-03-15 04:14:43 +01:00
## issue related to docker and xfs malfunction
2019-03-15 04:06:10 +01:00
problem: xfs with d_type/ftype false is problematic with docker https://docs.docker.com/storage/storagedriver/overlayfs-driver/
workaround: create a new xfs partition
create new directory in that new partition for docker
mkdir -p /media/data/docker
find docker.service
systemctl status docker
in order changes to take effect after upgrade, you need an override method (thanks https://success.docker.com/article/using-systemd-to-control-the-docker-daemon), do `systemctl edit docker` and add the location (thanks https://www.rb-associates.co.uk/blog/move-var-lib-docker-to-another-directory/) this way:
2019-03-15 04:06:10 +01:00
[Service]
ExecStart=
2019-03-15 04:06:10 +01:00
ExecStart=/usr/bin/dockerd -g /media/data/docker -H fd:// --containerd=/run/containerd/containerd.sock
reload systemd config
systemctl daemon-reload
force the usage of overlay2 (src https://docs.docker.com/storage/storagedriver/overlayfs-driver/). Add in `/etc/docker/daemon.json`
```json
{
"storage-driver": "overlay2"
}
```
2019-03-19 20:56:05 +01:00
2019-05-04 17:22:25 +02:00
## install cache system for nextcloud
2019-03-19 20:56:05 +01:00
2019-05-04 17:22:25 +02:00
install APCu and redis as backend cache system:
2019-03-19 20:56:05 +01:00
2019-05-04 17:22:25 +02:00
apt install php-apcu redis-server php-redis
2019-03-19 20:56:05 +01:00
[redis is significantly faster as a unix socket](https://guides.wp-bullet.com/how-to-configure-redis-to-use-unix-socket-speed-boost/), in `/etc/redis/redis.conf` put:
2020-04-27 17:56:42 +02:00
unixsocket /var/run/redis/redis-server.sock
2019-03-19 20:56:05 +01:00
unixsocketperm 775
2019-05-04 17:22:25 +02:00
restart redis to apply configuration changes
service redis-server restart
2019-03-19 20:56:05 +01:00
add www-data to redis group and restart apache2 to have proper permissions
gpasswd -a www-data redis
2020-03-12 21:27:57 +01:00
service apache2 restart # or nginx
2019-03-19 20:56:05 +01:00
configure APCU as memcache and redis for file locking, in `/var/www/html/nextcloud/config/config.php` add:
2021-04-12 14:57:21 +02:00
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.local' => '\OC\Memcache\Redis',
2019-03-19 20:56:05 +01:00
'memcache.distributed' => '\OC\Memcache\Redis',
'redis' => [
2020-04-27 17:56:42 +02:00
'host' => '/var/run/redis/redis-server.sock',
2019-03-19 20:56:05 +01:00
'port' => 0,
'dbindex' => 0,
'timeout' => 1.5,
],
2020-03-12 21:27:57 +01:00
https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/caching_configuration.html
2019-03-19 20:56:05 +01:00
2021-04-12 14:57:21 +02:00
using redis as memcache.local, suggested here https://help.nextcloud.com/t/solved-apcu-caching-gives-error/9403/5
2019-03-19 20:56:05 +01:00
## run occ operations
2020-04-27 17:56:42 +02:00
check new nextcloud version
2019-03-19 20:56:05 +01:00
2020-04-27 17:56:42 +02:00
su www-data -s /bin/sh -c "php /var/www/html/nextcloud/occ update:check"
noninteractive upgrade
2019-03-19 20:56:05 +01:00
2020-04-27 17:56:42 +02:00
su www-data -s /bin/sh -c "php /var/www/html/nextcloud/updater/updater.phar --no-interaction"
2019-03-19 20:56:05 +01:00
2020-04-27 17:56:42 +02:00
src https://docs.nextcloud.com/server/18/admin_manual/maintenance/update.html#batch-mode-for-command-line-based-updater
2019-04-03 01:57:43 +02:00
# extra references
http://blackhold.nusepas.com/2019/04/02/nextcloud-sobre-nginx-y-postgresql-paquetes-ofimaticos-collabora-o-onlyoffice-ds-sobre-docker/