How to Install OnlyOffice on Ubuntu 20.04 Server

In this tutorial, we will be looking at installing OnlyOffice on Ubuntu 20.04 server. OnlyOffice is a web application 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.
  • CRM (Customer Relationship Management)
  • Invoicing system
  • Project Management
  • Instant Messenger
  • Support more than 20 languages

OnlyOffice offers all basic tools for online businesses: email, document management, CRM, projects, calendar, a corporate social network with blogs, forums, and wiki, chat.

Open Source Community Edition vs Enterprise Edition

Just like WordPress, 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 for free whereas the enterprise edition lifetime license costs $1500 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 comparison between free and enterprise edition, visit this page.  It’s recommended that you use the official OnlyOffice Docker containers to install the free OnlyOffice Community Edition. Let’s get started.

Prerequisites

OnlyOffice consumes a whole lot of RAM. Your server needs to have at least 6GB of RAM to run OnlyOffice.

Step 1: Install Docker on Ubuntu 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.6, build 370c289

Step 2: Install OnlyOffice Community Edition Using Docker

OnlyOffice Community edition comprises the following 3 components.

  • OnlyOffice Groups: aka OnlyOffice community server
  • OnlyOffice Docs (document server): Online Office Suite
  • 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 \
    onlyoffice/documentserver

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 \
    -h your-domain.com \
    onlyoffice/mailserver

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 \
    onlyoffice/communityserver

Run the following command to check if the 3 Docker containers are running.

sudo docker ps

Step 3: Finish the Installation in Browser

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

your-server-ip

OnlyOffice will start initializing as shown below.

install onlyoffice on ubuntu 16.04 lts

On 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 icons 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 servers (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 onlyoffice-community-server
sudo docker rm onlyoffice-community-server

Then start community server with a port other than 80 like below. The 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 \
    onlyoffice/communityserver

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;
        server_name office.your-domain.com;

        error_log /var/log/nginx/onlyoffice.error;
        access_log /var/log/nginx/onlyoffice.access;

        location / {
              proxy_pass http://127.0.0.1:8080;
              proxy_set_header Host $http_host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-Forwarded-Proto $scheme;
        }
}

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 certbot

You also need to install the Certbot Nginx plugin.

sudo apt install python3-certbot-nginx

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 lines 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 certbot -a webroot -i nginx --agree-tos --redirect --hsts --staple-ocsp --email your-email-address -d office.your-domain.com -w /usr/share/nginx/onlyoffice/

You should see a congrats message indicating your TLS certificate is successfully obtained and installed. Your certificate and chain have been saved at /etc/letsencrypt/live/office.your-domain.com/fullchain.pem.

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

Auto-Renew TLS Certificate

Simply edit the crontab file of the 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!

Troubleshooting Tips

If your OnlyOffice is stuck at initialization (The portal start up process might take some time, please wait..), and you see the 502 bad gateway error when trying to access the /api/2.0/capabilities.json URL, it means the community server container has some problem.

You can log into the community server container with:

sudo docker exec -it onlyoffice-community-server /bin/bash

Then you can check the logs under /var/log/nginx/ directory.

As always, if you found this post useful,  subscribe to our free newsletter or follow us on  Twitter or like our Facebook page.

Rate this tutorial
[Total: 13 Average: 4.6]

6 Responses to “How to Install OnlyOffice on Ubuntu 20.04 Server

  • Hi, very nice tutorial. Many thanks.
    Just one question.

    How to install OnlyOffice as subdomain, so instead of mydomain.com into onlyoffice.mydomain.com ?

    Just creat a virtual host under Apache? Does this work with Docker?

  • Hello,
    im using ubuntu16.04

    this my nginx conf :
    server {
    listen 80;
    server_name oo.serveur.com;

    error_log /var/log/nginx/onlyoffice.error;

    location / {
    proxy_pass http://127.0.0.1:8080;
    }
    }

    i restart my computer and i see that :

    this my docker configuration :

    [email protected]:~$ sudo docker ps
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    797d3ddb8641 onlyoffice/communityserver “/usr/bin/dumb-ini…” 2 minutes ago Up 2 minutes 443/tcp, 3306/tcp, 5280/tcp, 9865-9866/tcp, 9871/tcp, 9882/tcp, 9888/tcp, 0.0.0.0:5222->5222/tcp, 0.0.0.0:8080->80/tcp onlyoffice-community-server
    eb4fcf3c20ea onlyoffice/mailserver “/bin/sh -c ‘expor…” 24 hours ago Up 7 hours 0.0.0.0:25->25/tcp, 0.0.0.0:143->143/tcp, 3306/tcp, 0.0.0.0:587->587/tcp, 8081/tcp onlyoffice-mail-server
    057848c2e769 onlyoffice/documentserver “/bin/sh -c ‘bash …” 24 hours ago Up 7 hours 80/tcp, 443/tcp onlyoffice-document-server

    can u tell me why i can see the onlyOffice page, and i see the nginx page thanks

  • raymond
    3 years ago

    Hi,

    After installing all and applied the certificates I can’t edit documents anymore. When opening a document for editing I receive an error message “unknown error”.

    How can I solve this issue?

    thanks

  • FYI for those installing this adblockers in your browser can interfere with the last install stage (when you go to browser) as it accesses google apis so you’ll need to allow/disable those to complete the install.

  • You have been of tremendous help. A humble request. Can you do a tutorial on installation of the latest OnlyOffice Workspace with Letsencrypt Certificate?

    It would be immensely helpful. There are several new features which makes it more closer to Spreadsheets in terms of features.

    I believe there are some changes to be made to the current tutorial as the Installation seems to go into an endless loop in the browser with the latest version

  • Scott Thompson
    2 months ago

    This is a very clear and concise installation guide. The document server comes up fine. The community server just restarts over and over. The mailserver never starts. Believe it or not, zero errors.

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