How to Install OnlyOffice on Ubuntu 16.04 LTS

March 17, 2020

In this tutorial, we will be looking at installing OnlyOffice on Ubuntu 16.04. For those of you who don’t know, OnlyOffice is a web app that provides online office suite, email server, document management, project management and CRM system all in one place.

OnlyOffice is formerly known as Teamlab Office. Some features are as follows:

  • 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.

OnlyOffice offers all necessary tools for business: email, document management, CRM, projects, calendar, corporate social network with blogs, forums, and wiki, chat.

Open Source Community Edition vs Enterprise Edition

Just like WordPress, you can sign up OnlyOffice’s 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 for free whereas the enterprise edition lifetime license costs $1500 per one server.

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

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

For more comparison between free and enterprise edition, visit this page.  It’s recommend that you use the official OnlyOffice Docker containers to install the free OnlyOffice Community Edition. The installation process is simple, so let’s get started.

Step 1: Install Docker on Ubuntu 16.04

Docker is included in 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 edit sources.list file with your favourite text editor such as nano.

sudo nano /etc/apt/sources.list

Scroll down to the bottom of this file and add the following line.

deb ubuntu-xenial main

install latest docker on Ubuntu

Press CTRL+O to save the file, then CTRL+X to exit. Next, run the following command to import the Docker GPG key to Ubuntu 16.04 system so that APT can verify package integrity during installation.

sudo apt-key adv --keyserver hkp:// --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

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-get install apt-transport-https ca-certificates

Now finally, update the package index on your Ubuntu 16.04 system and install docker-engine.

sudo apt update
sudo apt install docker-engine

Check Docker version.

docker -v

Sample output

Docker version 17.05.0-ce, build 89658be

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

systemctl status docker

ubuntu start docker daemon

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

sudo systemctl start docker

And enable auto-start with system boot:

sudo systemctl enable docker

Step 2: Install OnlyOffice Community Edition Using Docker

OnlyOffice Community edition comprises of the following 3 components.

  • OnlyOffice community server
  • OnlyOffice document server
  • OnlyOffice mail server

To install all of them, follow these steps.

First create a Docker network called onlyoffice.

sudo docker network create --driver bridge onlyoffice

Then install OnlyOffice document server with the below command. Simply copy and paste.

sudo docker run --net onlyoffice -i -t -d --restart=always --name onlyoffice-document-server 
    -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data 
    -v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice 

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 587:587 
    -v /app/onlyoffice/MailServer/data:/var/vmail 
    -v /app/onlyoffice/MailServer/data/certs:/etc/pki/tls/mailserver 
    -v /app/onlyoffice/MailServer/logs:/var/log 
    -v /app/onlyoffice/MailServer/mysql:/var/lib/mysql 

After that, issue this command to install OnlyOffice community server.

sudo docker run --net onlyoffice -i -t -d --restart=always --name onlyoffice-community-server 
    -p 80:80 -p 5222:5222 -p 443:443 
    -v /app/onlyoffice/CommunityServer/data:/var/www/onlyoffice/Data 
    -v /app/onlyoffice/CommunityServer/mysql:/var/lib/mysql 
    -v /app/onlyoffice/CommunityServer/logs:/var/log/onlyoffice 
    -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/DocumentServerData 
    -e DOCUMENT_SERVER_PORT_80_TCP_ADDR=onlyoffice-document-server 
    -e MAIL_SERVER_DB_HOST=onlyoffice-mail-server 

Step 3: Adding Swap Space

OnlyOffice consumes a whole lot of RAM. 6GB of RAM is required to run OnlyOffice. If your physical memory is small, you can easily add a swap file to increase the available RAM to use. First we use fallocate command to create a file. For example, create a file named swapfile with 4G capacity in root file system:

sudo fallocate -l 4G /swapfile

Then make sure only root can read and write to it.

sudo chmod 600 /swapfile

Format it to swap:

sudo mkswap /swapfile


Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
no label, UUID=h32b3e10-0779-4865-9ea0-6e2af8f3kea9

Enable the swap file

sudo swapon /swapfile

Step 4: Finish the Installation in Browser

Once it’s done, enter your server’s IP address in the browser address bar,


OnlyOffice will start initializing as shown below.

install onlyoffice on ubuntu 16.04 lts

In the next page, enter a password and email address to secure the OnlyOffice Portal. This is the admin account. You will need to confirm this email address.

onlyoffice portal setup

After clicking the continue button, you will be redirected to the home page of your OnlyOffice server. Clicking the big documents icon will take you to the online office suite where you can create and edit word documents, spreadsheets, presentation files. The 5 small icon at the bottom will respectively take you to project management, CRM, Mail, People and community page.

onlyoffice home page

To use a domain name instead of IP address, go to settings (gear icon) > DNS settings. And enter your domain name.

Onlyoffice custom domain name

Once you click the Save button, you can access your OnlyOffice server via your domain name, provided that a correct A record is set in DNS.

Editing Word Documents Online

onlyoffice online office suite

Project Management

onlyoffice project management

Managing Customer Relationships with CRM

manage relationships with customs with CRM

Email Server

Building an email server with OnlyOffice is really a piece of cake! No longer have to worry about esoteric configurations of Postfix and dovecot. The Mail module can be used to host multiple email domains. It also provides a web-based mail client which can aggregate all your email accounts in one place.

onlyoffice email server

Setting Up Nginx Reverse Proxy

It’s highly possible that you want other HTTP server (Apache or Nginx) to run on your server. So we recommend changing the port on which OnlyOffice listens and then set up Nginx reverse proxy. we can also conveniently enable HTTPS with Nginx later on.

First, stop and remove the community server container with the following command:

sudo docker stop container-id
sudo docker rm container-id

container-id can be obtained by running the command below.

sudo docker ps

Then start community server with a port other than 80 like below. Community server will be listening on port 8080.

sudo docker run --net onlyoffice -i -t -d --restart=always --name onlyoffice-community-server 
    -p 8080:80 -p 5222:5222 
    -v /app/onlyoffice/CommunityServer/data:/var/www/onlyoffice/Data 
    -v /app/onlyoffice/CommunityServer/mysql:/var/lib/mysql 
    -v /app/onlyoffice/CommunityServer/logs:/var/log/onlyoffice 
    -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/DocumentServerData 
    -e DOCUMENT_SERVER_PORT_80_TCP_ADDR=onlyoffice-document-server 
    -e MAIL_SERVER_DB_HOST=onlyoffice-mail-server 

Now let’s install Nginx.

sudo apt install nginx

And create a virtual host file.

sudo nano /etc/nginx/conf.d/onlyoffice-proxy.conf

Put the following text into the file. Replace the domain name with your actual domain name. The proxy_pass directive will pass all requests to OnlyOffice community server.

server {
        listen 80;
        error_log /var/log/nginx/onlyoffice.error;
        location / {

Save and close the file. Then test Nginx config and reload.

sudo nginx -t
sudo systemctl reload nginx

Now enter your domain name in the browser. You should see the OnlyOffice initialization page, which means you can access OnlyOffice via your domain name. Wait for it to finish initializing.

How to Enable HTTPS

Once the initialization is complete, we can obtain a free TLS certificate from Let’s Encrypt. Install Let’s Encrypt (certbot) client with:

sudo apt install letsencrypt

Since we’re using Nginx, it’s best to utilize the webroot plugin to obtain the certificate. We need to add a little configuration to the virtual host file.

sudo nano /etc/nginx/conf.d/onlyoffice-proxy.conf

Add the following directive to the file.

location ~ /.well-known/acme-challenge {
   root /usr/share/nginx/onlyoffice/;
   allow all;

Then create the /usr/share/nginx/onlyoffice/ directory.

sudo mkdir /usr/share/nginx/onlyoffice
sudo chown www-data:www-data /usr/share/nginx/onlyoffice -R

And reload nginx.

sudo systemctl reload nginx

Next, run the following command to obtain a TLS certificate. Replace red text with your actual email address and domain name for OnlyOffice.

sudo letsencrypt certonly --agree-tos --webroot --email your-email-address -d -w /usr/share/nginx/onlyoffice/

You should see a congrats message indicating your TLS certificate is successfully obtained. Your certificate and chain have been saved at /etc/letsencrypt/live/

Now Let’s install the cert. Open the virtual host file again.

sudo nano /etc/nginx/conf.d/onlyoffice-proxy.conf

Change it to the following. Replace red text accordingly.

server {
        listen 80;
        return 301 https://$server_name$request_uri;
server {
        listen 443 ssl http2;
        ssl_certificate /etc/letsencrypt/live/;
        ssl_certificate_key /etc/letsencrypt/live/;
        ssl_session_timeout 1d;
        ssl_session_cache shared:SSL:10m;
        ssl_session_tickets off;
        ssl_protocols TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        error_log /var/log/nginx/onlyoffice.error;
        access_log /var/log/nginx/onlyoffice.access;
        location / {
        location ~ /.well-known/acme-challenge {
            root /usr/share/nginx/onlyoffice/;
            allow all;

Save and close the file. Then test Nginx config and reload.

sudo nginx -t
sudo systemctl reload nginx

Now you should be able to access OnlyOffice in HTTPS protocol !

Auto Renew TLS Certificate

Simply edit the crontab file of root user.

sudo crontab -e

Put the following line into the file which will try to renew your cert once per day.

@daily certbot renew --quiet

Save and close the file. That’s it!

Need help?

Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!