How to compile the ONLYOFFICE Document Server from source code on Ubuntu

How to compile the ONLYOFFICE Document Server from source code on Ubuntu

ONLYOFFICE Document Server consists of web-based viewers and collaborative editors for text documents, spreadsheets and presentations that provide high compatibility with OOXML formats (docx, xlsx, pptx). The suite is distributed under GNU AGPL v3.0.

ONLYOFFICE Document Server can be integrated with various cloud storage platforms such as Nextcloud, ownCloud, Seafile, HumHub, Plone, etc., and can be integrated into your own solutions. Document Server can be used as part of the ONLYOFFICE Community Edition, a free open-source solution with an online editor and collaboration platform.


Build_tools allows users to install all necessary components automatically and compiles the latest online editor version from the source code.

In this tutorial, we will learn how to compile the ONLYOFFICE Document Server for your Ubuntu installation (Ubuntu 64-bit).

System Requirements

  • CPU: Dual core 2 GHz or better
  • RAM: 2GB or more
  • HDD: at least 40 GB of free space
  • At least 4 GB swap

Step 1: Install dependencies

If Python and Git are not installed on your computer, install them with the following command:

sudo apt-get install -y python git

Step 2: Create the Document Server source code

Build_tools repository clone:

git clone

Go to the appropriate directory:

cd build_tools/tools/linux

Run script:

./ server

Once complete, the default Document Server is available in the directory ../../out/linux_64/onlyoffice/documentserver/.

Step 3: Install and configure NGINX, PostgreSQL and RabbitMQ

Document Server uses NGINX as a web server and PostgreSQL as a database. RabbitMQ is also required for correct work.

1. Install and configure NGINX

Install NGINX with this command:

sudo apt-get install nginx

Disable the default website:

sudo rm -f /etc/nginx/sites-enabled/default

Prepare a new website. Create a file server / etc / nginx / sites-available / onlyoffice-document that contains the following data:

map $http_host $this_host {
  "" $host;
  default $http_host;
map $http_x_forwarded_proto $the_scheme {
  default $http_x_forwarded_proto;
  "" $scheme;
map $http_x_forwarded_host $the_host {
  default $http_x_forwarded_host;
  "" $this_host;
map $http_upgrade $proxy_connection {
  default upgrade;
  "" close;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Forwarded-Host $the_host;
proxy_set_header X-Forwarded-Proto $the_scheme;
server {
  listen [::]:80 default_server;
  server_tokens off;
  rewrite ^\/OfficeWeb(\/apps\/.*)$ /web-apps$1 redirect;
  location / {
    proxy_pass http://localhost:8000;
    proxy_http_version 1.1;
  location /spellchecker/ {
    proxy_pass http://localhost:8080/;
    proxy_http_version 1.1;

Add a symlink to the newly created website to the / etc / nginx / sites-available directory:

sudo ln -s /etc/nginx/sites-available/onlyoffice-documentserver /etc/nginx/sites-enabled/onlyoffice-documentserver

Restart NGINX:

sudo nginx -s reload

2. Install and configure PostgreSQL

Install PostgreSQL:

sudo apt-get install postgresql

Create a PostgreSQL database and users (enter ‘office only’ for users and passwords):

sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;"
sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"

Configure database:

psql -hlocalhost -Uonlyoffice -d onlyoffice -f ../../out/linux_64/onlyoffice/documentserver/server/schema/postgresql/createdb.sql

The above command is one line! Enter the ‘onlyoffice’ password when you are asked to provide a password for the only PostgreSQL user.

3. Install RabbitMQ

Install RabbitMQ with the following command:

sudo apt-get install rabbitmq-server

Step 4: Generate font data

Run the command:

cd out/linux_64/onlyoffice/documentserver/
mkdir fonts
LD_LIBRARY_PATH=${PWD}/server/FileConverter/bin server/tools/allfontsgen \
  --input="${PWD}/core-fonts" \
  --allfonts-web="${PWD}/sdkjs/common/AllFonts.js" \
  --allfonts="${PWD}/server/FileConverter/bin/AllFonts.js" \
  --images="${PWD}/sdkjs/common/Images" \
  --selection="${PWD}/server/FileConverter/bin/font_selection.bin" \
  --output-web='fonts' \

Step 5: Generate the theme of the presentation

Run the following command:

cd out/linux_64/onlyoffice/documentserver/
LD_LIBRARY_PATH=${PWD}/server/FileConverter/bin server/tools/allthemesgen \

Step 6: Run the Document Server

All ONLYOFFICE Document Server components are run as a foreground process. You need to separate the terminal console to run it or launch a special tool that allows it to run foreground processes in background mode.

Start the FileConverter service:

cd out/linux_64/onlyoffice/documentserver/server/FileConverter
LD_LIBRARY_PATH=$PWD/bin NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./converter

Start the Spell Checker service:

cd out/linux_64/onlyoffice/documentserver/server/SpellChecker
NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./spellchecker

Start the DocService service:

cd out/linux_64/onlyoffice/documentserver/server/DocService
NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./docservice

That is all! Now you can choose one of the options how to use the ONLYOFFICE Document Server (online editor) described in the introduction: integrated with cloud storage services, or integrated into your own solution, or together with the ONLYOFFICE Community Server.

Related posts

How to properly secure sysctl on Linux


How to Install an Ubuntu 20.04 LTS (Focal Fossa) Server


How to use BleachBit on Linux


How to Install Yarn on Ubuntu 20.04


What You Need to Know About Locked in Ubuntu 20.04


How to Manage, Change and Reset MySQL and MariaDB Root Passwords


How to Install Flatpaks on Ubuntu 20.04


How to Install a Plex Media Server on Ubuntu 20.04 / Linux Mint 20


How to Install and Configure Apache Hadoop on Ubuntu 20.04