Skip to content

How to Install OnlyOffice Document Server For Nextcloud, Fast & Easy

I’ve wasted a ridiculous amount of time trying to get the Collabora / LibreOffice / CODE platform integrated with my Nextcloud 11 server.  I wanted to have Google Docs-style editing, but it was turning out to be a massive headache.  One day, on accident, I stumbled on an OnlyOffice plugin for OwnCloud.  After a little digging, I found out it worked with NextCloud as well.  Less than 15 minutes later, I had the OnlyOffice Document Server packages installed on a second Ubuntu 16.04 server and it was fully integrated with my NextCloud server.

 

What You Need

 

For this guide, you will ultimately need the following:

  • A 2nd Ubuntu 16.04 or 16.10 Server
  • A Valid SSL Certificate (A FREE LetsEncrypt Certificate Will Do)
  • A Valid DNS Entry for Both Servers (for this guide, you are required to use onlyoffice.yourdomain.tld, custom OnlyOffice domains are out of the scope of this guide)

 

Installing Dependencies

 

OnlyOffice requires a few dependencies.  Mainly, nodejs, postgresql, and nginx.  In addition, we’ll need to enable a repo for up-to-date ttf-mscorefonts-installer packages.

 

First, let’s go ahead and add the needed repo’s.

 

echo "deb http://archive.ubuntu.com/ubuntu precise main universe multiverse" | sudo tee -a /etc/apt/sources.list
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -

 

Next, install postgresql.

 

sudo apt-get install postgresql

 

For the scope of this guide, the database must be called onlyoffice, and the username and passwords both need to be set to onlyoffice as well.  I suggest configuring a firewall, such as UFW, to secure your server.

 

To create the onlyoffice database and assign a username and password, do the following:

 

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

 

Next, install redis for caching.

 

sudo apt-get install redis-server

 

And finally, install rabbitmq.

 

sudo apt-get install rabbitmq-server

 

Install OnlyOffice Document Server

 

To install the OnlyOffice Document Server packages, we’ll need to add the repo, as well as its GPG key.

 

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

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

 

Update the Apt package manager’s list of available packages.

 

sudo apt-get install onlyoffice-documentserver

 

Now, we can install the OnlyOffice Document Server Packages.

 

sudo apt-get install onlyoffice-documentserver

 

After all packages have been installed, you should be able to browse to your OnlyOffice Document server via http://yourdomain.tld (https is not set up yet), although you will not be able to do anything with it directly beyond verifying it is working.  It will look like this.

 

OnlyOffice Document Server

 

The service name for the OnlyOffice Document Server is supervisor.  This service needs to be configured to start at boot, as well as redis-server, rabbitmq, and nginx.

 

sudo systemctl enable redis-server

sudo systemctl enable rabbitmq-server

sudo systemctl enable supervisor

sudo systemctl enable nginx

 

Those services will now start automatically on boot.  Next, you will need to obtain SSL certificates (I suggest using certbot to obtain them from Let Encrypt).  After you have obtained certificates, you can enable SSL on the OnlyOffice Document Server by doing the following.

 

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

 

Select everything in this file and delete.  Once the file is completely blank, paste or add the following contents to the file.  Be sure to edit the items in red, pertaining to your server name and SSL certificate locations.

 

include /etc/nginx/includes/onlyoffice-http.conf;
## Normal HTTP host
server {
listen 0.0.0.0:80;
listen [::]:80 default_server;
server_name onlyoffice.yourdomain.tld;
server_tokens off;
## Redirects all traffic to the HTTPS host
root /nowhere; ## root doesn't have to be a valid path since we are redirecting
rewrite ^ https://$host$request_uri? permanent;
}
#HTTP host for internal services
server {
listen 127.0.0.1:80;
listen [::1]:80;
server_name localhost;
server_tokens off;
include /etc/nginx/includes/onlyoffice-documentserver-common.conf;
include /etc/nginx/includes/onlyoffice-documentserver-docservice.conf;
}
## HTTPS host
server {
listen 0.0.0.0:443 ssl;
listen [::]:443 ssl default_server;
server_name onlyoffice.yourdomain.tld;
server_tokens off;
root /var/www/html;

ssl on;
ssl_certificate /etc/letsencrypt/live/onlyoffice.yourdomain.tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/onlyoffice.yourdomain.tld/privkey.pem;

ssl_ciphers "ECDHE-RSA-AES128-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA128:DHE-RSA-AES128-GCM-SHA384:DHE-RSA-AES128-GCM-SHA128:ECDHE-RSA-AES128-SHA384:ECDHE-RSA-AES128-SHA128:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES12$
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security max-age=31536000;
add_header X-Content-Type-Options nosniff;

######  The lines below will allow LetsEncrypt and/or Certbot to obtain & renew SSL certificates
location ~ /.well-known/acme-challenge {
root /var/www/onlyoffice/;
allow all;
}
include /etc/nginx/includes/onlyoffice-documentserver-*.conf;
}

 

Save and exit, then restart nginx and supervisor.

 

sudo systemctl restart nginx

sudo systemctl restart supervisor

 

Now you should be able to browse to your OnlyOffice Document Server using SSL / HTTPS (https://yourdomain.tld)

 

Next, you will need to add the OnlyOffice plugin to your NextCloud Server.  To do so, SSH into your NextCloud server, and download the plugin.

 

cd apps/
git clone https://github.com/ONLYOFFICE/onlyoffice-owncloud.git onlyoffice

 

Open your web browser and log in to your NextCloud server, then go to Settings > Admin > OnlyOffice.  Enter the address of your OnlyOffice Document Server (be sure to use https)

https://yourdomain.tld

 

OpenOffice NextCloud Configuration
Now, click Files on your NextCloud server, the click the plus button.  You should now have the option to create new Word Processor, Spreadsheet, and Presentation documents.  Enjoy!

 

OnlyOffice Nextcloud Create Document

 

Once you do so, you will now have your own Google Docs / Office 365 type of applications integrated on your NextCloud server!

 

OnlyOffice Spreadsheet Nextcloud

 

If you have any questions, please feel free to ask in the comments below.  Thanks for reading and have an awesome day!

10 thoughts on “How to Install OnlyOffice Document Server For Nextcloud, Fast & Easy

  1. koenigflo says:

    Why do we need a second server? Can’t OnlyOffice run on the same server as Nextcloud?

    Reply
    • Mike Smith says:

      You need a second server for this guide because the goal here was the easiest and quickest way to get it up an running. The default OnlyOffice Document Server deployment requires the database name to be onlyoffice (as well as its user/pass) and it requires the hostname and SSL certificate to also be onlyoffice.yourdomain.com So, for starters, to use the default config, you would have to name your NextCloud server onlyoffice.yourdomain.com. Then, becasue onlyoffice document server uses ports 80/443, which nextcloud also uses by default, you would either need to configure a reverse proxy, then change the ports nextcloud uses for http and https, then change the ports onlyoffice uses for http and https, then map those ports and paths appropriatly in your reverse proxy. So, get the idea? That kind of takes the “Fast & Easy” out of “How to install onlyoffice document server for nextcloud, fast & easy”…… Many people just want to try out onlyoffice before hosing their entire nextcloud infrastructure setting up a ton of customizations, changing ports, configuring reverse proxy’s, etc… This guide could be done in literally 3-4 minutes if you know what you’re doing. Its a fast and easy way to get it set up, that was the goal.

      In time, I will write some more guides, such as how to install nextcloud and onlyoffice on one server, but that will be a start to finish and include the nextcloud setup. That will be necessary to help most people get the reverse proxy set up properly.

      So, in a nutshell, to answer your question, you don’t HAVE to install it on a separate server, but its the quick and easy way.

      Thanks for reading,
      Mike

      Reply
      • koenigflo says:

        Thanks, understood. Although running *two* does not seem easy and quick to me.
        Nevertheless, it’s really a shame that Owncloud / Nextcloud dropped their simple Documents App….

        Reply
      • Laurentius Magnus says:

        Note, it is also very quick and easy to add several IPs to the server and have each server listen on separate IPs. E.g.:

        /etc/network/interfaces

        auto eth0
        iface eth0 inet static
        address 10.4.1.2/24
        gateway 10.4.1.1

        iface eth0 inet static
        address 10.4.1.200/24

        iface eth0 inet static
        address 10.4.1.201/24

        iface eth0 inet static
        address 10.4.1.202/24

        iface eth0 inet static
        address 10.4.1.203/24

        iface eth0 inet static
        address 10.4.1.204/24

        dns-search office.lan
        dns-nameserver 10.14.1.100

        Add as many IPs as you need and have each server, apache2, nginx or misc docker instances listen on discrete IPs on ports 80/443 without any collisions.

        Reply
  2. Holger Janning says:

    Thanks for this great guide. but, if i try to open a file via onlyoffice. i get a timeout whithin onlyoffice. onlyoffice is running under office.mydomain.tld. it it neccessary to run it on “ONLYoffice.mydmain.tld”?

    Reply
  3. Adri says:

    Hi, i just stuck on this script /etc/nginx/conf.d/onlyoffice-documentserver.conf

    it said nginx: [emerg] unexpected end of file, expecting “;” or “}” in /etc/nginx/conf.d/onlyoffice-documentserver.conf:47

    Before I changed the script from default, it was Ok, Document Server is running on the web

    Reply
    • Marc Pujol Maria says:

      Where is the error?

      Reply
    • Pasa Agni says:

      hi adri, i stuck too on this step, do you have the solution?

      Reply
      • Adri says:

        yes, i already got solution..that script above is wrong. There was typo code on that script, but i forgot where’s the error So I used other blog to resolved that issue.

        Reply
  4. Pingback: NextCloud avec le serveur OnlyOffice – Digital Box

Leave a Reply