Introduction
This page describes how Alexis Huxley installed the Nextcloud (a fork of ownCloud) server software on his own systems.
The basic procedure is:
- install Apache as a dumb back-end webserver
- configure Apache on the front-end webserver as a proxy
- install Nextcloud on the back-end webserver
- install Nextcloud plugins
- review security
Apache installation on the back-end
- Run:
apt -y install apache2
- Disable default sites and ports by running:
rm /etc/apache2/sites-available/* sed -r -i 's/^(Listen 80)/#\1/' /etc/apache2/ports.conf
- Set some environment varialbes needed in the rest of the procedure:
FQHN=$(hostname -f)
- Create /etc/apache2/sites-available/$FQHN-ssl.conf, containing:
<VirtualHost *:443> ServerName FQHN CustomLog ${APACHE_LOG_DIR}/FQHN-access.log combined ErrorLog ${APACHE_LOG_DIR}/FQHN-error.log LogLevel warn ServerSignature Off SSLEngine On SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key DocumentRoot /var/www/html </VirtualHost>
and substitute the markers by running:
sed -i "s/FQHN/$FQHN/g" /etc/apache2/sites-available/$FQHN-ssl.conf
- Run:
a2enmod ssl a2ensite $FQHN-ssl systemctl restart apache2
- Test by running:
date > /var/www/html/index.html w3m -dump https://$FQHN/ rm /var/www/html/index.html
Configuring Apache on the front-end as a proxy
- See the section ‘Heavyweight web services: proxying to a backend webserver’ of Configuring web services (revision 2).
Nextcloud installation
- On the backend webserver run:
PHP_VER=7.4 PKGS=( php$PHP_VER php$PHP_VER-common # provides php-ctype php$PHP_VER-curl php$PHP_VER-xml # provides php-dom php$PHP_VER-gd php$PHP_VER-common # provides php-iconf php$PHP_VER-json php$PHP_VER-xml php$PHP_VER-mbstring # php/openssl not identified # php/posix not identified # php/session not identified php$PHP_VER-xml # contains SimpleXML # php/xmlreader not identified # php/xmlwriter not identified php$PHP_VER-zip php-db php$PHP_VER-mysql # php/fileinfo not identified php$PHP_VER-bz2 php$PHP_VER-intl php$PHP_VER-ldap php-redis php-imagick ffmpeg php$PHP_VER-cli # provides pcntl ) apt -y install "${PKGS[@]}"
A few notes regarding that list:
- It’s taken from the official documentation.
- Don’t be tempted to use APCu instead of Redis; APCu has a bug.
- A good command for working out what provides various virtual pages is:
apt-cache showpkg <virt-pkg> # e.g. apt-cache showpkg php-ctype
- Edit /etc/apache2/sites-available/$FQHN-ssl.conf and add:
<Directory /var/www/html/> Require all granted AllowOverride All Options FollowSymLinks MultiViews <IfModule mod_dav.c> Dav off </IfModule> </Directory>
- Run:
a2enmod rewrite a2enmod env a2enmod dir a2enmod mime systemctl reload apache2
- Go here, click ‘Download for server’, then click ‘Details and Download options’ and copy the link for the ‘.tar.bz2’ download.
- On the backend webserver run:
wget <link> tar xjf ~/nextcloud-*.tar.bz2 --strip-components=1 --directory=/var/www/html
- Create /var/www/html/config/config.php containing only:
<?php $CONFIG = array( );
- Run:
chown -R www-data:www-data /var/www/html/
- Configure pretty URLs within Nextcloud by adding to /var/www/html/config/config.php between the round brackets:
'overwrite.cli.url' => 'https://nextcloud.pasta.freemyip.com', 'htaccess.RewriteBase' => '/',
- Add both the back-end and front-end webserver names to /var/www/html/config/config.php between the round brackets:
'trusted_domains' => array ( 0 => 'gnocchi.pasta.net', 1 => 'nextcloud.pasta.freemyip.com', ), 'overwritehost' => 'nextcloud.pasta.freemyip.com',
- Clone the trusted_domains setting to trusted_proxies; this will prevent a security warning later.
- Visit https://$FQHN/ or preferably the front-end webserver, which should prompt for admin account details and database details. Don’t fill anything in yet; we’ll do that in a moment.
- Create a database as follows:
apt -y install mariadb-server mariadb create database nextcloud; create user 'nextcloud'@localhost identified by '<set-a-password>'; grant all on nextcloud.* to 'nextcloud'@localhost; \q
- Go to https://<nextcloud-server>/.
- Set the admin’s login to admin.
- Set the admin’s password.
- Expand the ‘Storage & database’ section.
- Leave the default data folder.
- There is probably no option except to use MariaDB/Mysql, but if there is then set the database type to MySQL/MariaDB.
- Click ‘Finish Setup’ and wait.
- Dismiss the popup that appears about client software.
- To switch to the Beta Channel:
- Edit /etc/php/7.4/apache2/php.ini and set:
memory_limit = 512M
(Without this the download of the beta version will fail integrity checks.)
- Go to Settings–>Overview menu and change the update channel to Beta.
- Go to Settings–>Overview menu and click Open Updated and then Start Update and then follow the prompts.
- Edit /etc/php/7.4/apache2/php.ini and set:
- If you want to replace /var/www/html/data with a symlink to somewhere with more space then do so now.
Install plugins
- Install the following plugins:
- Customization->App Order
- Customization->Custom Menu
Dashboard–>OpenProject Integration (is only a dashboard applet)Integration–>Maps(low quality)Integration–>Rainloop(seems to be mail account + client, not just mail client)Multimedia–>GpxEdit(low quality)Office & Text–>Calendar(won’t allow Monday as first day or week)- Office & Text–>Carnet
- Office & Text–>Deck
Office & Text–>Mail(won’t work with some accounts being non-TLS accounts)- Office & Text–>Tasks
- Organization–>Bookmarks
- Organization–>Cookbook
- Tools–>News
- Disable the following standard plugins:
- Activity (pointless)
- Circles (can’t invite non-Nextcloud users; invitation mail not sent)
- Collabora Online (just too complicated to set up)
- Dashboard (just not useful for me)
- Recommendations (pointless)
- Tasks (clunky interface)
- Usage Survey (privacy)
Security
- Go to Settings–>Overview and wait for the Setup and Security Warnings section to be updated.
- To fix the warning ‘The Strict-Transport-Security HTTP header is not set to at least 5552000 seconds’:
- Edit /etc/apache2/sites-available/$FQHN-ssl.conf and add:
<IfModule mod_headers.c> Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains" </IfModule>
- Run:
a2enmod headers systemctl restart apache2
- Edit /etc/apache2/sites-available/$FQHN-ssl.conf and add:
- To fix the warning ‘Your installation has no default phone region set’:
- Edit/var/www/html/config/config.php and add:
'default_phone_region' => '49',
- Edit/var/www/html/config/config.php and add:
- To Fix the warning ‘No memory cache has been configured’:
- Install redis-server.
- Edit /etc/redis/redis.conf and change:
port 0 unixsocket /run/redis/redis-server.sock unixsocketperm 770
(
port 0
disables redis listening on TCP;unixsocketperm 770
allows those users in group redis to communicate with the redis server over the Unix socket.) - Edit/var/www/html/config/config.php and add:
'memcache.local' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'filelocking.enabled' => 'true', 'redis' => array ( 'host' => '/run/redis/redis-server.sock', 'port' => 0, 'timeout' => 0.0, ),
- Reboot.
- To Fix the warning ‘The database is missing some indexes’:
- Run:
su - www-data -s /bin/bash cd html php occ db:add-missing-indices exit
- Run:
- To fix the warning ‘This instance is missing some recommended PHP modules’:
- Run:
apt -y install php$PHP_VER-bcmath php$PHP_VER-gmp systemctl restart apache2
- Run:
- Disable Flows (I don’t need them) by:
- Run:
su - www-data -s /bin/bash cd html php occ config:app:set workflowengine user_scope_disabled --value yes
(See here for more details.)
- Run:
- Go to Settings–>Personal Info (this is as user ‘admin’) and set the email address (this is required for the next step to work)
- Go to Settings–>Basic Settings–>Email server and configure the mail server and send a test mail.
- Several apps prefer that Nextcloud uses the real cron rather than the built-in AJAX cron:
- Go to Settings–>Basic Settings–>Background Jobs and select ‘Cron’.
- Run:
apt -y install cron
- Run:
su - www-data -s /bin/bash -c "echo '*/5 * * * * php -f /var/www/html/cron.php' | crontab -"
- On the mail server host add an entry for www-data to /etc/aliases ans run:
newaliases
- Although I did not do it, I note it here for next time: The trash expiry needs to be set to something otherwise files hang around forever. See here for instructions on configuring.
- Configure the logging of client IPs.
- Go to https://scan.nextcloud.com/ and enter the server URL.