Linux Format

Installing Nextcloud

Nextcloud can handle all your document storage and sharing requiremen­ts. Who needs Dropbox?

-

There’s a number of ways to install Nextcloud, including the use of à la mode container systems such as Docker or Snap. These are easy to set up, but integratin­g them with CODE (and otherwise tweaking their internals) is more involved, so we’ll roughly follow the official guidance at https:// docs.nextcloud.com/server/latest/admin_manual/ installati­on/example_ubuntu.html. Use SSH to log in to your Ubuntu server (it should also work on Debian) and update, upgrade and install the packages with:

$ sudo apt update

$ sudo apt upgrade

$ sudo apt install apache2 mariadb-server libapache2­mod-php php-gd php-mysql php-curl php-mbstring

php-intl php-gmp php-bcmath php-xml php-imagick php-zip

You can copy and paste the package list (and subsequent code screeds) from the documentat­ion linked above to avoid tedium. Now we’ll set up our database server, using the freshly installed

MariaDB. This is technicall­y optional, because Nextcloud can use the flat-file database SQLite. This isn’t very performant, though, even with a single user, as the Nextcloud app is highly concurrent and SQLite only handles a single write operation at a time. Start the MariaDB console with $ sudo mysql .

MariaDB is command-compatible with

MySQL, but less Oracle-ey. Next we’ll set up a database and user for Nextcloud (using a wide character set for extra emoji and language support). Replace password with a suitable password:

CREATE USER ‘nextcloud’@’localhost’ IDENTIFIED BY

‘password’;

CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_ general_ci;

GRANT ALL PRIVILEGES ON nextcloud.* TO ‘nextcloud’@’localhost’; FLUSH PRIVILEGES; quit;

Now we’ll download the latest release of Nextcloud, extract the tarball, put the contents in Apache’s document root and set the appropriat­e permission­s:

$ wget https://download.nextcloud.com/server/

releases/latest.tar.bz2

$ tar xvjf latest.tar.bz2

$ sudo mv nextcloud /var/www

$ sudo chown -R www-data:www-data /var/www/

nextcloud

It’s good practice to check the MD5 checksums and PGP signatures of the tarball, but we’re short of space, so do check the docs for more details. Meanwhile, we’ve got a web server to configure. Run:

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

Now populate the configurat­ion file as follows:

Alias /nextcloud “/var/www/nextcloud/”

Require all granted

AllowOverr­ide All

Options FollowSymL­inks MultiViews

Dav off

It’s recommende­d (as we’ll do later) to run CODE on a subdomain, such as code.example.org. We’ve set up Nextcloud to run in a subdirecto­ry, example.org/ nextcloud in the above, for simplicity. This also allows users without domain names to follow. It’s easy to run Nextcloud as a subdomain (such as cloud.example.org)

instead, check the docs (https://docs.nextcloud.com/ server/latest/admin_manual/installati­on/source_ installati­on.html). Activate our new website with:

$ sudo a2ensite nextcloud.conf

We also need additional modules for Nextcloud to function correctly (some are enabled on Ubuntu 22.04):

$ sudo a2enmod rewrite headers env dir mime

We’re tantalisin­gly close to running Nextcloud for the first time. Restart Apache to pick up our changes:

$ sudo systemctl restart apache2

Now you should be able to access Nextcloud’s install script in a browser, by navigating to http://[ip address]/nextcloud (replacing with the server’s IP) or whatever domain you set it up on. Nextcloud requires an admin account, and to know the SQL database, user and password we set up. Once you’ve inputted all that, hit Install. This is a great time for a cup of tea.

You’re invited to install some Nextcloud apps (including Nextcloud Office). We’ll skip this for now; they can be added later. After closing the Nextcloud Hub welcome animation, you’re presented with some example documents. We don’t yet have the capability to view Microsoft DOCX files (or indeed LibreOffic­e

files) in the browser yet, so don’t get too excited.

Before you go any further, we strongly recommend setting up HTTPS encryption if you’re running Nextcloud on an internet-facing machine. This is easy to do with Let’s Encrypt’s Certbot tool, if you have a domain name already pointing at your Nextcloud instance. Install Certbot with:

$ sudo apt install python3-certbot-apache

Then, where example.domain.org (it might be a toplevel domain like example.org) is a domain under your control, with A records pointing at your server, run:

$ sudo certbot --apache -d example.domain.org

Follow the prompts and Certbot verifies that DNS records are all in order and if so adds a new site (called

nextcloud-le.conf) to the Apache config. You’re asked if you want to forward HTTP traffic to this site, which is a good idea.

Make sure that the certificat­e’s CommonName field matches Apache’s ServerName directive, and that both are set to the domain you want to access Nextcloud on, otherwise you will get errors.

It’s also possible to use the bundled self-signed certificat­e (which will result in browser warnings) if you don’t want to pay for domain registrati­ons. This is fine for testing locally, and is achieved with:

$ sudo a2enmod ssl

$ sudo a2ensite default-ssl

$ sudo systemctl reload apache2

You can now access your site at https:// [ip-address]/nextcloud, once you click through the foretold security risk warnings. You need your certificat­e to be signed by a reputable certificat­e authority to get rid of these warnings, otherwise anyone could pretend to be Google.com, for example.

From the top-right menu, select Administra­tion Settings. You’ll see some setup and security warnings. Ubuntu by default sets a low 128MB memory limit for PHP. Nextcloud is quite a memory-hungry beast and recommends at least 512MB. To change this, open the relevant PHP configurat­ion file with:

$ sudo nano /etc/php/8.1/apache2/php.ini

Search (Ctrl+w) for memory_limit and change it to

512M . You may be tempted to set an even higher limit, but this might be a bad idea if you’re on, for example, a cheap VPS with little memory. Apache and MariaDB can also be memory-hungry under pressure, so you probably want your server to have at least 2GB to run Nextcloud (with the recommende­d memory limit set) comfortabl­y. In our experience running with a 1GB VPS, the database is usually the first casualty under memory pressure. This results in Apache serving a rather unhelpful 500 – Internal Server Error message. Reload the Apache configurat­ion for changes to take effect.

If you have a valid HTTPS certificat­e, follow the guidance for setting up HSTS by clicking Security Tips. Any other issues the diagnostic picks up are likely minor, and they helpfully all include a link to address them. See the box (below) if you want to get rid of the memcache warning and speed things up a bit.

It’s worth spending some time uploading test files and perhaps installing some app recommenda­tions from the notificati­on bell. You might at this stage want to add a regular (non-admin) user, too. Oh, and always check the logs – they’re in the hamburger menu that opens from the left, under the Administra­tion heading.

 ?? ?? If your HTTPS certificat­es or proxy setup aren’t configured correctly (over the page) you will spend a long time battling with this error.
If your HTTPS certificat­es or proxy setup aren’t configured correctly (over the page) you will spend a long time battling with this error.
 ?? ??
 ?? ?? This swishy animation greets you on your first login to Nextcloud. Video files (and soon office docs) can be viewed in Nextcloud.
This swishy animation greets you on your first login to Nextcloud. Video files (and soon office docs) can be viewed in Nextcloud.
 ?? ??
 ?? ??
 ?? ?? Set your location on the main Nextcloud dashboard to get a helpful weather report
Set your location on the main Nextcloud dashboard to get a helpful weather report

Newspapers in English

Newspapers from Australia