How to Install OnlyOffice on Ubuntu 22.04/20.04 Server

This tutorial is going to show you how to install OnlyOffice in Ubuntu 22.04/20.04 on a single server. OnlyOffice (formerly Teamlab Office) is a web application that provides essential tools for online businesses all in one place: an online office suite, email server, document management, CRM, project management, calendar, and a corporate social network with blogs, forums, Wiki, and text chat.

OnlyOffice Features

  • It combines the best of MS office and Google Docs.
  • Offers more collaborative capabilities than Google Docs, fast real-time co-editing
  • More feature-rich than MS Office Online
  • It offers better support for MS Office formats than any other open-source office suite and is fully compatible with OpenDocument formats.
  • Integration with Box, OneDrive, Dropbox, Google Apps, Twitter, Facebook, LinkedIn.
  • Mail and calendar integration, mail autoreply, address book.
  • CRM (Customer Relationship Management)
  • Invoicing system
  • Project Management
  • Instant Messenger
  • Support more than 20 languages
  • And more

Open Source Community Edition vs Enterprise Edition

You can sign up for the OnlyOffice hosted service or you can set up a self-hosted OnlyOffice server which means you install OnlyOffice on your own server. The open-source community edition is free whereas the enterprise edition lifetime license costs $2200 per server.

The free edition includes a full-featured web office suite and the following features.

  • Online Document Editors
  • Document Management
  • Mail
  • Projects
  • CRM
  • Calendar
  • Community

For more comparisons between the free and enterprise editions, visit this page.

Requirement

OnlyOffice consumes a whole lot of CPU and RAM resources. Your server needs to have at least 4 CPU cores and 10GB of RAM to run OnlyOffice. It’s highly recommended to install OnlyOffice on a clean fresh server. OnlyOffice requires MySQL database server. If you use MariaDB database server, it won’t work.

OnlyOffice Community edition comprises the following 3 components.

  • OnlyOffice Groups: aka OnlyOffice community server.
  • OnlyOffice Docs (document server): Online Office Suite.
  • OnlyOffice mail server: it’s actually a clone of iRedMail

Step 1: Install Docker on Ubuntu 22.04/20.04 Server

Docker is included in the Ubuntu software repository. However, to ensure that we have the latest version, we will have to install it from Docker’s APT repository. Fire up a terminal window (CTRL+ALT+T), then run the following command to add Docker repository to your Ubuntu system.

echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list

Next, run the following command to import the Docker GPG key to Ubuntu system so that APT can verify package integrity during installation.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

And because this repository uses HTTPS connection, which I recommend all software repositories should be using, we also need to install apt-transport-https and ca-certificates package.

sudo apt install apt-transport-https ca-certificates

Finally, update the package index on your Ubuntu system and install docker-ce (Docker Community Edition).

sudo apt update

sudo apt install docker-ce

Once Docker is installed, the Docker daemon should be automatically started. You can check its status with:

systemctl status docker
systemctl status docker

If it’s not running, then start the daemon with this command:

sudo systemctl start docker

And enable autostart at boot time:

sudo systemctl enable docker

Check Docker version.

docker -v

Sample output:

Docker version 20.10.18, build 370c289

Step 2: Install OnlyOffice Mail Server Using Docker

Creating DNS MX Record

The MX record specifies which host or hosts handle emails for a particular domain name. For example, the host that handles emails for linuxbabe.com is mail.linuxbabe.com. If someone with a Gmail account sends an email to [email protected], then Gmail server will query the MX record of linuxbabe.com. When it finds out that mail.linuxbabe.com is responsible for accepting email, it then query the A record of mail.linuxbabe.com to get the IP address, thus the email can be delivered.

In your DNS manager, create a MX record for your domain name. Enter @ in the Name field to represent the main domain name, then enter mail.your-domain.com in the Value field.

iredmail email server create MX record

Note: The hostname for MX record can not be an alias to another name. Also, It’s highly recommended that you use hostnames, rather than bare IP addresses for MX record.

Your DNS manager may require you to enter a preference value (aka priority value). It can be any number between 0 and 65,356. A small number has higher priority than a big number. It’s recommended that you set the value to 0, so this mail server will have the highest priority for receiving emails. After creating MX record, you also need to create an A record for mail.your-domain.com , so that it can be resolved to an IP address. If your server uses IPv6 address, be sure to add AAAA record.

Hint: If you use Cloudflare DNS service, you should not enable the CDN feature when creating A record for mail.your-domain.com. Cloudflare does not support SMTP proxy.

Install MySQL 8 on Ubuntu 22.04/20.04

Note: OnlyOffice community server doesn’t work with MariaDB, you must use MySQL.

Run the following command to install MySQL 8.0 from the default Ubuntu repository.

sudo apt install mysql-server-8.0 mysql-server mysql-client

Once it’s installed, MySQL server will be automatically started, as can be seen with:

sudo systemctl status mysql
onlyoffice groups mysql database server

If it’s not running, you can start with:

sudo systemctl enable --now mysql

Log into MySQL console.

sudo mysql

Run the following commands to create database users.

CREATE USER 'onlyoffice_user'@'%' IDENTIFIED BY 'onlyoffice_pass';

CREATE USER 'mail_admin'@'%' IDENTIFIED BY 'mail_admin_pass';

Create the onlyoffice_mailserver database.

CREATE DATABASE 'onlyoffice_mailserver';

Grant permissions.

GRANT ALL PRIVILEGES ON * . * TO 'onlyoffice_user'@'%';

GRANT ALL PRIVILEGES ON * . * TO 'mail_admin'@'%';

GRANT ALL PRIVILEGES ON * . * TO 'mail_admin'@'localhost';

FLUSH PRIVILEGES;

Log out of MySQL console.

exit;

We also need to configure MySQL to listen on the Docker network interface, because the OnlyOffice Mail container will try to access MySQL server via the Docker interface.

sudo nano /etc/mysql/mysql.conf.d/mysqld.conf

Find the following two lines.

bind-address            = 127.0.0.1
mysqlx-bind-address     = 127.0.0.1

Change them to

bind-address            = 127.0.0.1,172.17.0.1
mysqlx-bind-address     = 127.0.0.1,172.17.0.1

Save and close the file. Then restart MySQL.

sudo systemctl restart mysql

Install OnlyOffice Mail with Docker

First, create a Docker network called onlyoffice.

sudo docker network create --driver bridge onlyoffice

Allow connections from the 172.17.0.0/24 and 172.18.0.0/24 network. For example, if you use the UFW firewall, run the following command.

sudo ufw insert 1 allow in from 172.17.0.0/24

sudo ufw insert 1 allow in from 172.18.0.0/24

sudo ufw insert 1 allow in from 172.20.0.0/24

We need to temporarily stop UFW.

sudo systemctl stop ufw

Next, execute the following command to install OnlyOffice mail server. Replace with red-colored text with you own domain name.

sudo docker run --net onlyoffice --privileged -i -t -d --restart=always --name onlyoffice-mail-server \
    -p 25:25 -p 143:143 -p 993:993 -p 587:587 -p 465:465 -p 8081:8081 \
    -e MYSQL_SERVER=172.17.0.1 \
    -e MYSQL_SERVER_PORT=3306 \
    -e MYSQL_ROOT_USER=mail_admin_pass \
    -e MYSQL_ROOT_PASSWD=mail_admin_pass \
    -e MYSQL_SERVER_DB_NAME=onlyoffice_mailserver \
    -v /app/onlyoffice/MailServer/data:/var/vmail \
    -v /app/onlyoffice/MailServer/data/certs:/etc/pki/tls/mailserver \
    -v /app/onlyoffice/MailServer/logs:/var/log \
    -h mail.your-domain.com \
    onlyoffice/mailserver

Run the following command to check if the Docker containers is running.

sudo docker ps

You can also check if the Docker container is listening on the email ports (TCP 25, 143, 587, 993, 465).

sudo ss -lnpt | grep docker-proxy

output:

LISTEN 0      4096                                     0.0.0.0:993        0.0.0.0:*    users:(("docker-proxy",pid=3309956,fd=4))                                                                                                          
LISTEN 0      4096                                     0.0.0.0:587        0.0.0.0:*    users:(("docker-proxy",pid=3309978,fd=4))                                                                                                          
LISTEN 0      4096                                     0.0.0.0:143        0.0.0.0:*    users:(("docker-proxy",pid=3310024,fd=4))                                                                                                          
LISTEN 0      4096                                     0.0.0.0:465        0.0.0.0:*    users:(("docker-proxy",pid=3310001,fd=4))                                                                                                          
LISTEN 0      4096                                     0.0.0.0:8081       0.0.0.0:*    users:(("docker-proxy",pid=3309935,fd=4))                                                                                                          
LISTEN 0      4096                                     0.0.0.0:25         0.0.0.0:*    users:(("docker-proxy",pid=3310046,fd=4))

Wait a moment, then log into MySQL console.

sudo mysql

Check if the database tables are created.

USE onlyoffice_mailserver;

SHOW TABLES;

Sample output:

+---------------------------------+
| Tables_in_onlyoffice_mailserver |
+---------------------------------+
| access_control                  |
| admin                           |
| alias                           |
| alias_domain                    |
| amavis_rules                    |
| anyone_shares                   |
| api_keys                        |
| api_sa_training_history         |
| api_sa_training_queue           |
| bayes_expire                    |
| bayes_global_vars               |
| bayes_seen                      |
| bayes_token                     |
| bayes_vars                      |
| checkhelo                       |
| checkhelo_blacklist             |
| checkhelo_tracking              |
| checkhelo_whitelist             |
| checkspf                        |
| deleted_mailboxes               |
| dkim                            |
| domain                          |
| domain_admins                   |

Step 1: Install OnlyOffice Docs on Ubuntu 22.04/20.04

OnlyOffice document server depends on PostgreSQL, Node.js, Redis Server, RabbitMQ server, and Nginx web server.

Install PostgreSQL Database Server

The PostgreSQL team always strive to make performance improvements with every new version. Run the following 4 commands to install the latest version of PostgreSQL.

echo "deb [signed-by=/etc/apt/keyrings/postgresql.asc] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/keyrings/postgresql.asc

sudo apt update

sudo apt install -y postgresql postgresql-contrib

PostgreSQL database server will automatically start and listens on 127.0.0.1:5432. The postgres user will be created on the OS during the installation process. It’s the super user for PostgreSQL database server. By default, this user has no password and there’s no need to set one because you can use sudo to switch to the postgres user and log into PostgreSQL server.

sudo -u postgres -i psql

Create a database for OnlyOffice Docs.

CREATE DATABASE onlyoffice;

Create a database user.

CREATE USER onlyoffice;

Set a password for this user.

ALTER USER onlyoffice WITH ENCRYPTED PASSWORD 'secret_password';

Grant permission.

GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;

Exit.

\q

Install NodeJS from the official repository

OnlyOffice document server requires Nodejs version 14.0+, but the version in Ubuntu repository might be outdated, so we will need to install Node.js from upstream repository.

Add Node.js repostiory.

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

Install Node.js.

sudo apt install nodejs -y

Check Node.js version.

node -v

Sample output:

v14.21.1

Install Redis Server and RabbitMQ

sudo apt install redis-server rabbitmq-server

Check their status.

systemctl status redis-server

systemctl status rabbitmq-server

You should see they are active (running). If rabbitmq-server failed to start, that’s mostly because of low memory on the machine or an invalid hostname. Redis server listens on 127.0.0.1:6379. RabbitMQ listens on 0.0.0.0:25672 and 0.0.0.0:4369

Install OnlyOffice Docs

Add OnlyOffice Docs repository. (You might be wondering why this repository uses debian as the distro name. Because it works for all Debian-based distros including Ubuntu.)

echo "deb https://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice-docs.list

Import GPG key.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5

Update repository index and install OnlyOffice Docs. (Note that OnlyOffice uses Nginx web server.)

sudo apt update

sudo apt-get install ttf-mscorefonts-installer onlyoffice-documentserver nginx

During installation, you will be asked to enter the OnlyOffice database user password that you created eariler.

onlyoffice document server postgresql password

Then you need to agree to the Microsoft fonts end-user license agreement. Press the Tab key and hit Enter.

truetype core fonts for the web EULA

Then use the arrow key to select Yes and hit Enter.

configuring ttf-mscorefonts-installer onlyoffice

An Nginx server block will be installed as /etc/nginx/conf.d/ds.conf. (It’s actually a symbolic link to /etc/onlyoffice/documentserver/nginx/ds.conf.) The OnlyOffice document server is a nodejs web application and Nginx acts as the reverse proxy. /var/www/onlyoffice/documentserver/ is the web root directory.

Once the installation is finished, enter your server’s public IP address in a web browser, and you should see “ONLYOFFICE Docs Community Edition installed”

onlyoffice document server ubuntu

To check the version number of the document server, you can use the following command.

apt search onlyoffice-documentserver

Sample output.

onlyoffice-documentserver/squeeze,now 7.2.1-23 amd64 [installed]
  Online editors for text documents, spreadsheets, and presentations

If you encounter the following error during installation, it might be that there’s an error in your Nginx configuration files. Run sudo nginx -t or sudo journalctl -eu nginx to find out.

dpkg: error processing package onlyoffice-documentserver (--configure):
 installed onlyoffice-documentserver package post-installation script subprocess returned error exit status 1
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Errors were encountered while processing:
 onlyoffice-documentserver
E: Sub-process /usr/bin/dpkg returned an error code (1)

Enabling HTTPS for the Document Server

The following steps show how to obtain and install a free Let’s Encrypt TLS certificate.

First, we need to edit the OnlyOffice Nginx server block file.

sudo nano /etc/nginx/conf.d/ds.conf

We add a server_name directive like below. Don’t forget to set DNS A record for onlyoffice.your-domain.com.

include /etc/nginx/includes/http-common.conf;
server {
  listen 0.0.0.0:80;
  listen [::]:80 default_server;
  server_tokens off;
  server_name onlyoffice.your-domain.com;

  include /etc/nginx/includes/ds-*.conf;
}

Save and close the file. Reload Nginx for the changes to take effect.

sudo systemctl reload nginx

Then install certbot (Let’s Encrypt) client and the Nginx plugin.

sudo apt install certbot python3-certbot-nginx

Create a directory for Let’s Encrypt ACME protocol.

sudo mkdir -p /var/www/onlyoffice/documentserver/letsencrypt/.well-known/acme-challenge/

Change the owner to www-data.

sudo chown www-data:www-data /var/www/onlyoffice/documentserver/letsencrypt/ -R

Grant permissions.

sudo apt install acl

sudo setfacl -R -m u:www-data:rwx /var/www/onlyoffice/

Next, run the following command to obtain a free TLS certificate using the Nginx plugin.

sudo certbot --webroot --agree-tos --redirect --hsts --staple-ocsp -w /var/www/onlyoffice/documentserver/letsencrypt/ --email [email protected] -d onlyoffice.your-domain.com

Where:

  • --webroot: Use the webroot plugin.
  • --agree-tos: Agree to terms of service.
  • --redirect: Force HTTPS by 301 redirect.
  • --hsts: Add the Strict-Transport-Security header to every HTTP response. Forcing browser to always use TLS for the domain. Defends against SSL/TLS Stripping.
  • --staple-ocsp: Enables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.
  • -w: specify the webroot directory.

Within a few seconds, you shall see a message like below, which means the TLS certificate is successfully obtained.

onlyoffice document server https

Visit https://onlyoffice.your-domain.com in web browser to verify OnlyOffice document server is running correctly in HTTPS mode.onlyoffice docs https ubuntu

Step 4: Install OnlyOffice Groups on Ubuntu 22.04/20.04

Install Mono on Ubuntu

Since OnlyOffice is written in .NET, we need to install Mono, which is an open-source .NET framework.

sudo apt install gnupg ca-certificates

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list

echo "deb https://d2nlctn12v279m.cloudfront.net/repo/mono/ubuntu focal main" | sudo tee /etc/apt/sources.list.d/mono-extra.list

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5

sudo apt update

sudo apt install mono-complete mono-webserver-hyperfastcgi ffmpeg 

Install .NET runtime environment

Several OnlyOffice services such MailAggregator, MailCleaner and MailWatchdog need to run on .NET.

Ubuntu 22.04 users can easily install it with the following command.

sudo apt install dotnet6

Then create a symbolic link.

sudo ln -s /usr/bin/dotnet /usr/share/dotnet/dotnet

Ubuntu 20.04

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

sudo dpkg -i packages-microsoft-prod.deb

sudo apt update

sudo apt install dotnet-sdk-6.0

Installing Elasticsearch

We can install Elasticsearch from the official repository with the following commands. Elasticsearch is written in Java programming language, so we also install the default-jre-headless (Java runtime environment) package in the last command.

sudo apt-get install -y apt-transport-https

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

sudo apt-get update

sudo apt-get install -y openjdk-8-jre-headless elasticsearch=7.16.3

Note: You must install JDK version 8 and ElasticSearch version 7.16.3.

By default, the Elasticsearch systemd service is disabled. You can start and enable it with the following commands.

sudo systemctl enable --now elasticsearch

Then check the status.

systemctl status elasticsearch

We can see that it’s now enabled and running, and it uses 1.3G RAM. (Hint: If this command doesn’t quit immediately, press Q to make it quit.)

parsedmarc-elasticsearch-ubuntu 20.04

If ElasticSearch is using too much RAM, you may want to reduce the memory footprint by creating the /etc/elasticsearch/jvm.options.d/memory.options file.

sudo nano /etc/elasticsearch/jvm.options.d/memory.options

Add the following two lines in this file.

-Xms1g
-Xmx1g

This means the Java virtual machine used by ElasticSearch will use 1G RAM. Note that there should not be any space at the beginning of each line. Restart ElasticSearch for the change to take effect.

sudo systemctl restart elasticsearch

Install OnlyOffice Groups (aka OnlyOffice Community Server)

Note: The following command will automatically install mysq-server. If you use MariaDB server, please back up your database before running the commands.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5

echo "deb https://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list

sudo apt update

sudo apt install onlyoffice-communityserver

During installation, you will be asked to set a password for the onlyoffice database.

onlyoffice community server mysql password

At the end of the installation, OnlyOffice community server will try to restart the elasticsearch.service. You might encounter the following error:

Job for elasticsearch.service failed because a timeout was exceeded.

To fix this error, you need to increase the timeout period.

sudo mkdir /etc/systemd/system/elasticsearch.service.d

Then create a file.

sudo nano /etc/systemd/system/elasticsearch.service.d/startup-timeout.conf

Add the following lines in this file.

[Service]
TimeoutStartSec=180

Save and close the file. Then reload systemd.

sudo systemctl daemon-reload

And continue the installation.

sudo apt install onlyoffice-communityserver

This time it should be working.

A dozen of systemd services will be activated during the installation.

onlyoffice groups systemd service

If you found the following line.

Could not execute systemctl: at /usr/bin/deb-systemd-invoke line 142.

It means some of the services failed to start due to heavy server load at this point.

You can check if they are running. For example,

systemctl status monoserve.service

Output:

 monoserve.service - FastCGI Mono server
     Loaded: loaded (/lib/systemd/system/monoserve.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-09-21 12:06:58 UTC; 28min ago
    Process: 3066983 ExecStartPre=/bin/bash -c test -e /var/run/onlyoffice || install -m 755 -o onlyoffice -g nginx -d /var/run/onlyoffice; rm -f /va>
   Main PID: 3066986 (mono)
      Tasks: 44 (limit: 629145)
     Memory: 1.6G
        CPU: 5min 11.859s
     CGroup: /system.slice/monoserve.service

If later you find OnlyOffice Community Server doesn’t work, it’s probably because some of these systemd services are working correctly.

You can run the following commands to check the status of multiple services at the same time.

sudo systemctl status onlyofficeFeed onlyofficeSocketIO onlyofficeTelegram onlyofficeThumb onlyofficeUrlShortener onlyofficeRadicale

sudo systemctl status onlyofficeIndex onlyofficeNotify onlyofficeBackup onlyofficeStorageMigrate onlyofficeStorageEncryption

sudo systemctl status onlyofficeMailAggregator onlyofficeMailWatchdog onlyofficeMailCleaner onlyofficeThumbnailBuilder god elasticsearch

If a service isn’t running, you can try restarting it. For example, I found the onlyofficeSocketIO.service failed to start, so I run the following command to restart it.

sudo systemctl restart onlyofficeSocketIO.service

The god.service can tell you which services failed to start.

sudo systemctl status god.service

Sample output:

 god.service - God Service
     Loaded: loaded (/lib/systemd/system/god.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-09-21 12:03:42 UTC; 49min ago
   Main PID: 3063505 (god)
      Tasks: 18 (limit: 629145)
     Memory: 53.5M
        CPU: 47.922s
     CGroup: /system.slice/god.service
             └─3063505 /usr/bin/ruby /usr/bin/god -c /etc/god/god.conf -P /var/run/god.pid -l /var/log/god.log

Sep 21 12:52:08 ubuntu god[3063505]: onlyofficeMailWatchdog start command exited with non-zero code = 1
Sep 21 12:52:14 ubuntu god[3063505]: onlyofficeMailAggregator start command exited with non-zero code = 1
Sep 21 12:52:21 ubuntu god[3063505]: onlyofficeMailCleaner start command exited with non-zero code = 1
Sep 21 12:52:23 ubuntu god[3063505]: onlyofficeMailWatchdog start command exited with non-zero code = 1
Sep 21 12:52:29 ubuntu god[3063505]: onlyofficeMailAggregator start command exited with non-zero code = 1
Sep 21 12:52:36 ubuntu god[3063505]: onlyofficeMailCleaner start command exited with non-zero code = 1
Sep 21 12:52:38 ubuntu god[3063505]: onlyofficeMailWatchdog start command exited with non-zero code = 1
Sep 21 12:52:44 ubuntu god[3063505]: onlyofficeMailAggregator start command exited with non-zero code = 1
Sep 21 12:52:51 ubuntu god[3063505]: onlyofficeMailCleaner start command exited with non-zero code = 1
Sep 21 12:52:53 ubuntu god[3063505]: onlyofficeMailWatchdog start command exited with non-zero code = 1

If restarting a service also failed, you need to check the journal logs to find out why, e.g,

sudo journalctl -eu onlyofficeMailAggregator.service

Step 5: Enabling HTTPS for OnlyOffice Community Server

The following steps show how to obtain and install Let’s Encrypt TLS certificate to encrypt our HTTP connections.

First, we need to edit the OnlyOffice Nginx server block file.

sudo nano /etc/nginx/sites-enabled/onlyoffice

Scroll down to the server {...} section. We add a server_name directive in this file like below. Don’t forget to set DNS A record for office.your-domain.com.

server {
        listen 80;
        server_name office.your-domain.com;

        charset utf-8;
        add_header Access-Control-Allow-Origin $header_access_control_allow_origin;
        add_header X-Frame-Options $header_x_frame_options;

        large_client_header_buffers 4 16k;

        set $X_REWRITER_URL $the_scheme://$the_host;

        if ($http_x_rewriter_url != '') {
                set $X_REWRITER_URL $http_x_rewriter_url ;
        }

        include /etc/nginx/includes/onlyoffice-communityserver-*.conf;
}

Save and close the file. Reload Nginx for the changes to take effect.

sudo systemctl reload nginx

Then install certbot (Let’s Encrypt) client and the Nginx plugin.

sudo apt install certbot python3-certbot-nginx

Next, run the following command to obtain a free TLS certificate using the Nginx plugin.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d office.example.com

Where:

  • --nginx: Use the nginx plugin.
  • --agree-tos: Agree to terms of service.
  • --redirect: Force HTTPS by 301 redirect.
  • --hsts: Add the Strict-Transport-Security header to every HTTP response. Forcing browser to always use TLS for the domain. Defends against SSL/TLS Stripping.
  • --staple-ocsp: Enables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.

Within a few seconds, you shall see a message like below, which means the TLS certificate is successfully obtained.

onlyoffice community server https ubuntu

Step 6: OnlyOffice Portal Setup

Visit https://office.your-domain.com in web browser to launch the OnlyOffice portal setup wizard. All you need to do is enter your email address and set a password for the admin account. Then you will be able to log in.

onlyoffice community server https ubuntu

If you see the 502 bad gateway error, it’s probably your server runs out of RAM or there’s not enough CPU resources, causing the monoserve.service to shut down.

onlyoffice 502 app crashed

You can check its journal logs with:

sudo journalctl -eu monoserve

You can use the following command to check the amount of free RAM on your server.

free -m

If your server has enough CPU and RAM resources, then simply wait a minute then reload the web page a few times and it should take you to the port setup page.

Integrate OnlyOffice Docs with OnlyOffice Community Server

Go to the OnlyOffice settings -> Integration -> Document Service. There are 3 values you need to enter.

  • Document Editing Service Address: https:/onlyoffice.your-domain.com
  • Document Service address for requests from the Community Server: https://onlyoffice.your-domain.com
  • Community Server address for requests from the Document service: https://office.your-domain.com

onlyoffice document service integration

Save the settings. Then you will be able to open and edit office documents (DOCX, XLSX, PPTX).

You may also want to read:

Rate this tutorial
[Total: 5 Average: 4.2]

2 Responses to “How to Install OnlyOffice on Ubuntu 22.04/20.04 Server

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here