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.
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
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!
Once you do so, you will now have your own Google Docs / Office 365 type of applications integrated on your NextCloud server!
If you have any questions, please feel free to ask