Nextcloud 18 (NextcloudHub) was released and there are many new News about it:
see the ChangeLog
But now let us install the new NextcloudHub with postreSQL and php7.4-fpm on Debian Buster.
Requirements:
– an VPS with Debian Buster installed
– shell access and appropriate rights
– One DNS A and possibly AAAA record for our Apache vhost
Step 1: Install postgreSQL
First, we install the postgreSQL as Database-Server:
apt install -y postgresql postgresql-contrib
Now you can connect to postgreSQL with:
root@db01:/# sudo -u postgres psql psql (11.5 (Debian 11.5-1+deb10u1)) Type "help" for help. postgres=#
you can get information about connection with:
postgres=# \conninfo You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432".
and end session with:
postgres-# \q
Step 2: Install Apache2
With the following command we will install the Apache-Webserver:
apt install -y apache2 apache2-utils
Step 3: Install php7.4-fpm an recommended moduls
Before installing php7.4 we have to add the following Repositories to Debian Buster:
sudo apt -y install lsb-release apt-transport-https ca-certificates sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury_php.list sudo apt update
Now we can start to install the needed packages with the following command:
apt install -y php7.4-cli php7.4-common php7.4-mbstring php7.4-gd php-imagick php7.4-intl php7.4-bz2 php7.4-xml php7.4-pgsql php7.4-zip php7.4-dev php7.4-curl php7.4-fpm php-dompdf redis-server php-redis php-smbclient php7.4-ldap
Step 4: Configure Apache2 and php7.4-fpm
Now we enable the needed modules in Apache2 with:
a2enmod proxy_fcgi setenvif mpm_event rewrite headers env dir mime ssl http2
and after that we activate php7.4-fpm
:
a2enconf php7.4-fpm
now we have edit the apache2.conf
to allow the usage of .htaccess
-files:
nano /etc/apache2/apache2.conf
and change the following code:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
To enable HTTP/2, we need to add this line to apache2.conf
:
Protocols h2 h2c http/1.1
now we have to prepare the php.ini
for nextcloud:
nano /etc/php/7.4/fpm/php.ini
extend with the following directives:
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
and adjust the following Lines:
max_execution_time = 300 max_input_time = 600 memory_limit = 512M upload_max_filesize = 10240M
Afterwards, the web server
and php7.4-fpm
must be restarted:
systemctl restart apache2 php7.4-fpm
Step 5: Install Certbot and other tools
To request a ssl-sert from LetsEncrypt we use Certbot
and the apache-plugin
:
apt install python-certbot-apache certbot wget curl sudo unzip
Step 6: Create Database
Before we can install Nextcloud, we first have to create a database in postgreSQL. To do this, we execute the following commands:
sudo -u postgres psql
then execute:
CREATE USER nextcloud WITH PASSWORD 'your-password'; CREATE DATABASE nextclouddb TEMPLATE template0 ENCODING 'UNICODE'; ALTER DATABASE nextclouddb OWNER TO nextcloud; GRANT ALL PRIVILEGES ON DATABASE nextclouddb TO nextcloud; \q
Step 7: Download Nextcloud and create filesystem
Now it’s time to download the latest Release of Nextcloud 18 from nextcloud:
wget https://download.nextcloud.com/server/releases/latest-18.zip
and unzip the downloaded archive:
unzip latest-18.zip
Afterwards we move the folder nextcloud
to the right place.
we move the entire folder into the path /var/www/html/
mv nextcloud /var/www/html/ chown -R www-data:www-data /var/www/html/nextcloud
You can delete the downloaded archive now:
sudo rm latest-18.zip
For our nextcloud-files we prepare a directory outside of /var/www/html/nextcloud
:
mkdir /nextcloud_data
and change the owner to www-data
:
chown -R www-data:www-data /nextcloud_data
The document-root for Apache is now /var/www/html/nextcloud
Step 8: Create Apache2 vHost and secure with SSL
To create an Apache vhost, we simply create a new .conf
in /etc/apache2/sites-available/
:
nano /etc/apache2/sites-available/001-nextcloud.conf
add the following content and adjust your names:
<VirtualHost *:80> ServerName nextcloud.your-domain.tld ServerAdmin webmaster@your-domain.tld DocumentRoot /var/www/html/nextcloud ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
then we activate this site and disable the default vHost:
a2ensite 001-nextcloud.conf a2dissite 000-default.conf systemctl reload apache2
Since we want to reach the site of course via https, we create a LetEncrypt certificate. The easiest way to do this is with Certbot, which we already installed above:
certbot --apache --rsa-key-size 4096
In the last query, we confirm with „2“ that a redirect should occur.
Certbot then creates a second vhost configuration file, which we then process again:
nano /etc/apache2/sites-available/001-nextcloud-le-ssl.conf
we add the following block under DocumentRoot
-directive:
<IfModule mod_headers.c> Header always set Strict-Transport-Security "max-age=15768000; preload" Header always set Referrer-Policy "strict-origin-when-cross-origin" # Prevent MIME based attacks Header always set X-Content-Type-Options "nosniff" Header always set X-Frame-Options "SAMEORIGIN" </IfModule> # SSL Configuration - uses strong cipher list - these might need to be downgraded if you need to support older browsers/devices SSLEngine on SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 SSLHonorCipherOrder On <Directory /var/www/html/nextcloud/> Require all granted AllowOverride All Options FollowSymLinks MultiViews <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/html/nextcloud SetEnv HTTP_HOME /var/www/html/nextcloud Satisfy Any </Directory>
then we have to reload the webserver again:
systemctl reload apache2
Step 9: Configure Nextcloud
For final configuration, we call our domain in the browser:
and enter the corresponding data, as DB host
we enter localhost
and the data directory is /nextcloud_data
.
You have to finish the Installation with the Button on the botton.
Now, let’s take Nextcloud’s config.php
to configure the recommended memory cache:
nano /var/www/html/nextcloud/config/config.php
add the following code:
'memcache.local' => '\OC\Memcache\Redis', 'memcache.locking' => '\\OC\\Memcache\\Redis', 'redis' => array( 'host' => 'localhost', 'port' => 6379, ),
It looks like this:
In the basic settings, we customize the background tasks and use cron
:
and configure the user’s cron job accordingly www-data
(adjust path and/or user if you use another one):
sudo crontab -u www-data -e
add the following line at the end:
*/5 * * * * php7.4 -f /var/www/html/nextcloud/cron.php
Restart Apche2 and php-fpm:
systemctl restart apache2 && sudo systemctl restart php7.4-fpm
Last, we have to add some indices and convert some tables in nextclouddb to big int with the following two commands as user www-data:
sudo -u www-data php7.4 /var/www/html/nextcloud/occ db:add-missing-indices sudo -u www-data php7.4 /var/www/html/nextcloud/occ db:convert-filecache-bigint
then refresh your browser and Check the Security and Setup Warnings in Settings Overview.
Step 10: ONLYOFFICE if failed during initialization
If the app documentserver_community get not installed during initialization, you could manually install via shell:
cd /var/www/html/nextcloud/apps/ sudo -u www-data wget https://github.com/nextcloud/documentserver_community/releases/download/v0.1.5/documentserver_community.tar.gz sudo -u www-data tar -xvzf documentserver_community.tar.gz rm documentserver_community.tar.gz
Check if the app ONLYOFFICE is installed and enabled then enable Community Document Server too, the seetings will published autmatically.
Check that the document server is enabled in ONLYOFFICE Settings:
This is a Guide for fresh Install, if you used OnlyOffice before, then clear all settings in OnlyOffice-App before enabling Community Document Server.
If you forget, the settings will not publish automatically.
the URL for OnlyOffice is:
https://nextcloud.your-domain.tld/index.php/apps/documentserver_community/
Do not forget to configure your mail-settings
Now we have a freshly installed NextcloudHub and can enjoy… Remember: If you find issues within the Nextcloud, then report here on GitHub.
Problems with the tutorial? Then comment below or contact me per Mail or Mastodon.
Happy nextclouding and do not forget to share 🙂
12 Gedanken zu „How to install Nextcloud 18 aka NextcloudHub on Debian Buster with postgreSQL 11.5 php7.4-fpm Apache2 and HTTP/2“
Moin Markus,
Wenn ich versuche die PPA zu adden kommt folgendes:
sudo add-apt-repository -y ppa:ondrej/php
Traceback (most recent call last):
File „/usr/bin/add-apt-repository“, line 95, in
sp = SoftwareProperties(options=options)
File „/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py“, line 109, in __init__
self.reload_sourceslist()
File „/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py“, line 599, in reload_sourceslist
self.distro.get_sources(self.sourceslist)
File „/usr/lib/python3/dist-packages/aptsources/distro.py“, line 93, in get_sources
(self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Raspbian/buster
Hast du einen Lösungsansatz? Ich komme nicht weiter.
Hallo Tom,
da hat sich anscheinend etwas geändert. Ich konnte es wie folgt lösen und habe es im Artikel angepasst:
Gruß
Markus
Hallo Markus
Danke für der tutorial. Die installation hat geklapt.
Habe noch frage aber.
Ich kann kein url im CookBook hinzufügen, z.b. https://www.bbc.co.uk/food/recipes/ , da kommt immer bei jede url fehlermeldung „could not find recipe elements“.
Weist wo rann das liegen kann??
Danke
Gruss
Hallo,
Nutze ich nicht, aber schau mal hier:
https://github.com/mrzapp/nextcloud-cookbook/issues/115
Gruß Markus
Hallo Markus,
vielen Dank für die Anleitung. Hast Du mit php7.4 die App „Files External“ zum Laufen gebracht?
Ich erhalte hier immer eine Fehlermeldung.
„Invalid characters passed for attempted conversion, these have been ignored at …/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php#149“
Liebe Grüße,
Robert
Hallo Robert,
Nutze ich nicht. Es gibt noch einige Issues mit php7.4 wie ich gesehen habe. Am besten ein neues auf GitHub aufmachen.
Liebe Grüße
Markus
Wie bekomme ich es hin zwei Nextclouds auf einem Server unter der gleichen IP zu erreichen?
Einen zweiten vhost, eine zweite Datenbank und einen weiteren Ordner für Daten und Nextcloud anlegen, also quasi das Tutorial noch einmal ausführen und die Namen anpassen. Aber nichts überschreiben.
Hallo Markus,
zunächst vielen Dank für deine Mühen für das sehr schöne und detailierte Tutorial.
Ich habe es ausprobiert, habe aber Anmerkungen dazu
Step 6:
Da müsste das Kopieren des entpackten Downloads von nextcloud weg, also das mv nextcloud/* /var/www/html/
Hinterher verschiebst du den Ordner nämlich.
Step 7:
Da erzeugst du einen Vhost für eine Subdomain, aber die Dateien liegen im Verzeichnis der Standardinstallation.
Ich habe z.B. alles in der Standardinstallation belassen und nur diese Apache-Konfigurationsdateien bearbeitet, weil ich ich den certbot (Let’s Encrypt) bereits installiert hatte und auch schon ein Zertifikat hatte. Mein nextcloud ist also per https:///nextcloud erreichbar.
Step 8:
Da sollte nach der Konfiguration von nextclod (blaues Fenster) stehen, dass man das abschicken soll, bevor man weitere Schritte macht.
Man könnte es sich zwar denken, aber wenn alles neu ist, kommt man ins Grübeln.
Step 9:
Ich habe es nicht geschafft, Onlyoffice zum Laufen zu bringen, weil egal was ich bei ‚Document Editing Service address‘ eingeben keine Verbindung hergestellt werden kann.
Gebe ich dort wie in deiner Hardcopy ein:
https:///nextcloud/index.php/apps/onlyoffice/
… ekomme ich die Fehlermeldung:
Fehler beim Anschließen (Client error: `GET https:///nextcloud/apps/onlyoffice/healthcheck` resulted in a `401 Unauthorized` response: {„message“:“Current user is not logged in“} )
Die Eintrag im Feld in deiner Beschreibung passt nicht zur Einrichtung unter eine Subdomain https://nextcloud. wie unter Step 7 angelegt, aber zu einer Installation wie ich sie habe unter https:///nextcloud. Man sieht zudem nicht alles was eingetragen wurde, denn der hintere Teil ist abgeschnitten.
Viele Grüße
Martin
Hallo Martin,
danke für Dein Feedback.
zu Step 6: das war ein entweder „mv nextcloud/* /var/www/html/“ oder „mv nextcloud /var/www/html/“, Erklärung stand im Text. Vielleicht etwas missverständlich, daher habe ich die erste Variante rausgenommen. Ziel des Tutorials ist eine frische NC unter /var/www/html/nextcloud zu haben.
Step 7:
Wo die Dateien liegen ist im Endeffekt egal und hat nichts damit zu tun, ob Du eine Subdomain oder eine Domain nutzt. Die Dateien werden immer mit Document-Root angegeben. Ziel ist hier nextcloud.your-domain.tld unter dem Document-Root wie oben genannt. Wenn Du 5-10 Nextclouds auf einem Server hast, hilft die Ordnerstruktur etwas oder auch, wenn Du nur ein WordPress oder sonst etwas daneben hast 🙂
Step 8: ja, sollte man sich denken, habe es noch hingeschrieben
Step 9:
Habe hinzugefügt, dass die OnlyOffice-App leer sein muss, bevor der Document-Server aktiviert wird, da nur dann die Einstellungen automatisch vorgenommen werden. Zur Sicherheit habe ich auch noch die richtige URL eingetragen. …/onlyoffice/ am Ende ist nicht richtig.
Den Screenshot werde ich noch mal anpassen, auch wenn es irrelevant ist, da die Einstellungen ja automatisch gesetzt werden.
Danke Dir und Viele Grüße zurück
Markus
Hey Markus
thanks for the tutorial, would you please add Nextcloud 18 for Plesk with Apache2 and HTTP2 and/or Nginx?
and which one do u recommend more, Apache2 or Nginx for Plesk.
Hi, I prefer Apache2,
you can add the the following block in https-settings, but adjust the paths:
Markus