IT in Education

Collaboration with Nextcloud documents

nextcloudONLYOFFICE allows you to edit documents in the browser. To use ONLYOFFICE, you will need an ONLYOFFICE Document Server. This article describes how to install the open source Community Edition of ONLYOFFICE Document Server, using Ubuntu, which could be deployed in-house or on AWS.


You Ubuntu server will need the minimum specification:

  • CPU: dual core 2 GHz or better
  • RAM: 2GB or more
  • HDD: at least 50GB of free space
  • Swap: at least 4GB of swap

If you are building an AWS EC2 Ubuntu instance, t3a.small is a good starting point, but I typically use t3a.medium. Note that this method of installation uses Ubuntu snap, which I couldn't get to work when using Docker. So whilst Docker seemed easier initially, I've now gone back to just using Ubuntu.

Once you have your Ubuntu server set up (I'm using Ubuntu 22.04 LTS for this article), you can log on and run the following commands.

$ sudo apt update
$ sudo apt dist-upgrade

Now we can install and configure PostgreSQL. Important: Make sure you change the password to your own password.

$ sudo apt install postgresql
$ sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH PASSWORD 'your_db_password';"
$ sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice OWNER onlyoffice;"

Next we can install Rabbit

$ sudo apt install rabbitmq-server

Install Document Server

Now that the prerequisites have been installed you are ready to install ONLYOFFICE.

Run the following commands.

$ mkdir -p -m 700 ~/.gnupg
$ curl
-fsSL | gpg --no-default-keyring --keyring gnupg-ring:/tmp/onlyoffice.gpg --import
$ chmod 644 /tmp/onlyoffice.gpg
$ sudo chown root
:root /tmp/onlyoffice.gpg
$ sudo mv
/tmp/onlyoffice.gpg /usr/share/keyrings/onlyoffice.gpg

Now we can add the OnlyOffice repository.

$ echo "deb [signed-by=/usr/share/keyrings/onlyoffice.gpg] squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list
$ sudo apt update

Now you can install mscorefonts:

$ sudo apt install ttf-mscorefonts-installer

Now we can install OnlyOffice Document Server:

$ sudo apt install onlyoffice-documentserver

Enter the PostgreSQL password when requested. You will now be able to browse to the IP address for this server and see the welcome screen for ONLYOFFICE.

A quick test

If you run the following command, you'll be able to browse to http://IP_ADDRESS/example to see the document server in action.

sudo systemctl start ds-example

SSL Certificate

You will need to create two DNS A records (e.g. and and point them to the IP address of your host.

Now you are ready to run the following commands to install CertBot which is client software for using Let's Encrypt.

$ sudo snap install core; sudo snap refresh core
$ sudo snap install --classic certbot
$ sudo ln -s /snap/bin/certbot /usr/bin/certbot

 With certbot installed you can run the following command to configure it for your domain:

$ sudo certbot --nginx

In the wizard that follows, do the following:

  1. Enter your email address.
  2. Accept the Terms of service.
  3. Sign up to Electronic Frontier Foundation mailing list if you want to.
  4. Enter the domain name of your document server (e.g.

Your ONLYOFFICE document server should now be accessible at

In the future, the certificate should auto-renew, but to test to see if this is working, run the following command:

$ sudo certbot renew --dry-run

Configure Nextcloud

Before you can configure OnlyOffice in Nextcloud you will need the secret that was automatically created as part of the installation.

$ cat /etc/onlyoffice/documentserver/local.json

Make a note of the value against services > CoAuthoring > secret > session > string.

Now you can log on to your Nextcloud instance.

  1. Click your Avatar > Apps.
    1. Select the Office & text category in the left pane.
    2. Click the Download and enable button for the ONLYOFFICE connector.
  2. Click your Avatar > Settings.
  3. Select ONLYOFFICE in the left pane.
  4. Enter the URL for your new Document Editing Service address.
  5. Enter the Secret key from the local.json file.

You should now find that you can edit documents inside Nextcloud.

Additional settings

Here are some further Nextcloud settings that you can make:

  • Restrict access to ONLYOFFICE for a selection of Nextcloud groups.
  • Select file formats to automatically open in ONLYOFFICE.
  • There's even a security watermarking feature.

 Please see this article for further information on how to perform these steps.

Thanks for visiting,