How to Integrate OnlyOffice with WordPress on Ubuntu Server
As you may probably know, you can use WordPress to set up a website or blog and OnlyOffice is a self-hosted online office document server. This tutorial will be showing you how to integrate OnlyOffice with WordPress, so you will be able to edit office documents (DOCX, XLSX, PPTX, etc.) right from the WordPress web interface.
Feature of the WordPress OnlyOffice Integration App
- Full-featured text editor is available online with all the functionality of desktop editors.
- 100% view, conversion, print, and pagination fidelity.
- It allows you to add links, tables, charts, insert images, auto shapes, formulas, text objects and manipulate them, create bulleted or numbered lists.
- Supports DOCX, XLSX, PPTX, TXT file editing and saving. You can also save the file in other formats like ODT, ODS, ODP, DOC, XLS, PPT, PPS, EPUB, RTF, HTML, HTM.
- Fully compatible with Office Open XML formats: .docx, .xlsx, .pptx
- Auto-save your files, so you won’t lose your work.
- Supports Latin, CJK (Chinese, Japanese, Korean) characters.
Prerequisites
OnlyOffice document server requires at least a 2-core CPU and 2GB RAM. To make it run smoothly with WordPress, I recommend using a server with a 4-core CPU and 4GB RAM. You can buy a powerful VPS from Contabo at very little cost. If there’re many users, you should consider upgrading the server specs.
To complete this guide, you need to have a working WordPress server. If you haven’t already done so, please read the following article to set up WordPress server first.
Then read the following instructions to integrate OnlyOffice and WordPress. The OnlyOffice document server and WordPress server can be installed on two different hosts.
Let’s get started.
Step 1: Install OnlyOffice Document Server on Ubuntu
OnlyOffice document server depends on PostgreSQL, Node.js, Redis Server, RabbitMQ server and Nginx. The following steps are tested on a Ubuntu 22.04 server but should also be applicable to Linux distributions in the Debian family.
Install PostgreSQL on Ubuntu
PostgreSQL is available from the default Ubuntu repository. The PostgreSQL team always strives to make performance improvements with every new version. Run the following commands to install the latest version of PostgreSQL from the postgresql.org repository.
echo "deb [signed-by=/etc/apt/keyrings/postgresql.asc] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list sudo mkdir -p /etc/apt/keyrings/ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/keyrings/postgresql.asc sudo apt update sudo apt install -y postgresql postgresql-contrib postgresql-15 postgresql-client-15
Then create the onlyoffice
database.
sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;"
Create the onlyoffice
user.
sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
Grant permission.
sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"
Note: Both the username and password must be onlyoffice
.
Install NodeJS from official repository
OnlyOffice document server requires nodejs version 14.0+, but the version in Ubuntu repository is outdated, so we will need to install Node.js from upstream repository.
Add Node.js repostiory.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
Install Node.js.
sudo apt install nodejs -y
Check Node.js version.
node -v
Sample output:
v14.21.1
Install Redis server and Rabbitmq
sudo apt install redis-server rabbitmq-server
Check their status.
systemctl status redis-server systemctl status rabbitmq-server
You should see they are active (running). If rabbitmq-server
failed to start, that’s mostly because of low memory on the machine or invalid hostname. Redis server listens on 127.0.0.1:6379
. RabbitMQ listens on 0.0.0.0:25672
and 0.0.0.0:4369
Install OnlyOffice document server
Add OnlyOffice repository with the following command. (You might be wondering if it’s ok to use the Debian squeeze repository on Ubuntu. Don’t worry. This OnlyOffice repository is meant for all Debian and Ubuntu releases.)
echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list
Import OnlyOffice public key.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
Update local package index and install OnlyOffice document server. Note that the onlyoffice-documentserver
package will install nginx-extras
as a dependency, so if an Apache web server is running, you need to stop it first.
sudo apt update sudo apt install onlyoffice-documentserver
During the installation process, you will be asked to enter PostgreSQL password for onlyoffice. Enter “onlyoffice” (without double quotes).
You also need to accept the Microsoft license terms in order to install TrueType core fonts from Microsoft.
An Nginx server block will be installed as /etc/nginx/conf.d/ds.conf
. (It’s actually a symbolic link to /etc/onlyoffice/documentserver/nginx/ds.conf
.) The OnlyOffice document server is a nodejs web application and Nginx acts as the reverse proxy. /var/www/onlyoffice/documentserver/
is the web root directory.
Once the installation is finished, enter your server’s public IP address in a web browser, and you should see “ONLYOFFICE Docs Community Edition installed”
To check the version number of the document server, you can use the following command.
apt search onlyoffice-documentserver
Sample output.
onlyoffice-documentserver/squeeze,now 7.2.1-23 amd64 [installed]
Online editors for text documents, spreadsheets, and presentations
If you encounter the following error during installation, it might be that there’s an error in your Nginx configuration files. Run sudo nginx -t
to find out.
dpkg: error processing package onlyoffice-documentserver (--configure):
installed onlyoffice-documentserver package post-installation script subprocess returned error exit status 1
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Errors were encountered while processing:
onlyoffice-documentserver
E: Sub-process /usr/bin/dpkg returned an error code (1)
Step 2: Enabling HTTPS for the Document Server
To connect WordPress to OnlyOffice document server, the latter must be running in HTTPS mode (Both the WordPress server and user browsers will need to make contact with document server). The following steps show how to obtain and install Let’s Encrypt TLS certificate.
First, we need to edit the OnlyOffice Nginx server block file.
sudo nano /etc/nginx/conf.d/ds.conf
We add a server_name directive like below. Don’t forget to set DNS A record for onlyoffice.your-domain.com
.
include /etc/nginx/includes/http-common.conf;
server {
listen 0.0.0.0:80;
listen [::]:80 default_server;
server_tokens off;
server_name onlyoffice.your-domain.com;
include /etc/nginx/includes/ds-*.conf;
}
Save and close the file. Reload Nginx for the changes to take effect.
sudo systemctl reload nginx
Then install certbot (Let’s Encrypt) client and the Nginx plugin.
sudo apt install certbot python3-certbot-nginx
Next, run the following command to obtain a free TLS certificate using the Nginx plugin.
sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d onlyoffice.your-domain.com
Where:
--nginx
: Use the nginx plugin.--agree-tos
: Agree to terms of service.--redirect
: Force HTTPS by 301 redirect.--hsts
: Add the Strict-Transport-Security header to every HTTP response. Forcing browser to always use TLS for the domain. Defends against SSL/TLS Stripping.--staple-ocsp
: Enables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.
Within a few seconds, you shall see a message like below, which means the TLS certificate is successfully obtained.
Visit https://onlyoffice.your-domain.com
in web browser to verify OnlyOffice document server is running correctly in HTTPS mode.
Step 3: Install WordPress OnlyOffice Integration App
Log into WordPress web interface as an admin, and go to the Plugins page to search the OnlyOffice plugin. Install and activate it.
After that, go to WordPress Settings page, select ONLYOFFICE
tab on the left pane and enter the domain name for OnlyOffice (https://onlyoffice.example.com) in Document Editing Service Address
field.
After saving the above setting, you can create new WordPress Posts and insert .docx, .xlsx, .pptx files to your WordPress posts.
Note: OnlyOffice is only available in the default WordPress Block Editor. You can’t use it in the classic editor.
Installing OnlyOffice Document Server and WordPress on the Same Host
The OnlyOffice Document server uses Nginx as web server.
If you have an existing WordPress server running with Nginx, then there’s no damage to your WordPress server when installing OnlyOffice on the same machine. It will remove nginx-core
and install nginx-extras
package, so there’ll be a little downtime, but your configurations will be intact.
If you have an existing WordPress server running with Apache web server, and you want to install OnlyOffice on the same machine, then you have two choices:
- Stop/remove Apache, use Nginx as the web server for both WordPress and OnlyOffice. You can use the WordPress Nginx config in this tutorial.
- Configure Nginx as a reverse proxy for Apache.
How to Upgrade OnlyOffice Document Server
When a new version of OnlyOffice document server comes out, you simply use the apt package manager to upgrade to the new version.
sudo apt update;sudo apt upgrade
Note that the new version will override your customizations in the /etc/nginx/conf.d/ds.conf
file. I recommend backing up this file with the following command, so you will be able to easily restore your custom configurations.
cat /etc/nginx/conf.d/ds.conf | sudo tee /etc/nginx/conf.d/ds.conf.backup
Wrapping Up
I hope this tutorial helped you with integrating OnlyOffice with WordPress. As always, if you found this post useful, then subscribe to our free newsletter. You can also follow us on Google+, Twitter or like our Facebook page.
Worked very well. But in the end I lost https. I got a message that cetrificate was OK, and the webbpage showed https:. But after having run the Script to Integrate OnlyOffice and NextCloud I get only http and not safe.
How can I solve that?
Hello. I followed the tutorial, and I was able to get to the Nextcloud login page through plain http. But when I run certbot to get the SSL certificate, I get the following error:
Any suggestion?
Okay, for anyone having the same problem, you can fix it by placing this location in the server block of nginx.conf, instead of the one detailed in the tutorial:
Notice the caret before the tilde, that will prevent nginx from processing other regexp.
Thank you so much! @Juan
Excellent tutorial, thanks a lot!!!
It worked flawlessly, except when i tried to finish the install wizard. It was failing to login in the database. I check the ip of the containers and it doesn’t match the ip assigned to mariadb user, so I choose to use (the lazy approach) 172.%.%.% and then the install wizard worked:
I ran set_configuration.sh, but now Onlyoffice is complaining about it can’t save the document, I will see what’s happening…
same here 🙁
ya no funciono vrD?
Hello, the tutorial is good and works too. There is only the problem, if I reach my server over http, everything works fine. Also OnlyOffice works. If I switch to https, Nextcloud will continue to work, but OnlyOffice will stop working. The error: “Document can not be saved and loaded” appears and I have to cancel. When I remove the block for ssl in nginx.conf, everything works again. How do I get OnlyOffice running via https?
Hello. I think this is a problem in OnlyOffice itself. You should ask OnlyOffice developers to fix this error.
Does anybody know why the menu isn’t “complete”? I’m not able to see and therefore change the different menu-tabs as mentioned on the official onlyoffice site:
In your screenshot there are no tabs either…
I’m getting “App “Onlyoffice” cannot be installed because it is not compatible with this version of the server.” when trying to enable Onlyoffice (using either the script or the GUI). I guess the nextcloud:fpm image isn’t compatible with the current onlyoffice/documentserver:latest image…
Dear All I getting an error when I run “sudo bash set_configuration.sh”.
I can note edit or open files in nextcloud. Please help.
Hi, please go to the NextCloud Apps page to update ONLYOFFICE to the latest version, enable it, then run this script again.
Dear Xiao,
Thank you so much for your reply. I did this but now I got new error.
“The document could not be saved. Please check connection settings or contact your administrator.
When you click the ‘OK’ button, you will be prompted to download the document.
Find more information about connecting Document Server here.”
I know it is weird to asking for help again and again but I will be much obliged for your help
I ran into the same problem as Syed when trying to create and edit my first document with ONLYOFFICE:
——–
“The document could not be saved. Please check connection settings or contact your administrator.
When you click the ‘OK’ button, you will be prompted to download the document.
Find more information about connecting Document Server here.”
——–
Someone at https://help.nextcloud.com/t/warning-the-document-could-not-be-saved/26550/6 managed to solve it saying:
“After lots of messing around, I was able to resolve this for our setup. First, I put the generated certs in a certs folder under the app_data > data folder for our docker volume. Then I added https: for https://nginx-server/ 9 to our Server address for internal requests from the Document Editing Service under admin. Previously, it was set as the default http.”
…but I’m not sure how that’s done in the CLI. Would be great if you can update this tutorial with the steps. Thanks!
Dear All,
First of all I would like to thank Mr. Xiao Guo. He is the life saver and real hero. I wish I could meet him once in my life. He solved my problem by messenger, email reply and whatever medium I adopted to reach him. I am in debt for the whole of my life. When I texted he was going to sleep but still he replied to me. I am so grateful to him. Literally I have no words to thank him. He is the buddy I ever found. He is so helpful and supportive. I just say Love you Xiao Guo. Best wishes from my side. Keep up the good work.
My VPS was down by service provider. Now I installed this as the same way as mentioned in that tutorial. This works like a charm. It is the best ever tutorial I ever found. This is the method on internet. Hats off to you. Bundle of thanks.
Hello,
Thanks for this guide. Very helpful.
Do you know how can I run two separate nextcloud installations with different domains on the same server ?
I’ve tried a lot of things but not able to do that.
Many thanks for your help.
Bruno
As I can fix the ip of the containers, in the first installation all right, when I turned on the virtual machine, the ip of the container had changed
You can use wildcard to create an user on a specific network range like so:
Thanks for the write-up, it’s very detailed. I can’t get it to work. I have a droplet on Digital Ocean. I install docker, and manage to get up to composing the yml file. Using “sudo docker ps” does show the 3 containers working. However, when I go to my domain, or the IP address, nothing loads.
I can install nextcloud via snap, and regular apt method, and that seems to work. I can’t figure out what I’m doing wrong, and have had to refresh my OS several times.
Update: It works as instructed when using Ubuntu 16.04.
I still can’t get it working on Ubuntu 18.04, even though it all downloads.
Thank you for this tutorial, it is perfect 🙂
I followed it, there are several months but how to update the containers with the latest version?
Thank You.
All is working except ssl: I’m using local domain and bind9 dns with samba4 plugin on the other server. And certbot does not want to find a record for my local domain in dns server and to create certificates, so I gave up for now and using http.
Hi Xiao
All works great! But I then abled SSL and now I have the onlyoffice error ‘The document could not be saved. Please check connection settings or contact your administrator.
When you click the ‘OK’ button, you will be prompted to download the document.’
I have tried the fix you suggested but I then loose all access to nextcloud. Any ideas?
Thanks!
Hi Xiao,
this tutorial is a great help for this topic and after digging the tls-redirection-“no saved”-issue i found the solution to avoid it.
If you are interested in about it, send me an email account, I will describle it for you.
Brilliant tutorial! Thanks a lot. Everything worked fine, but after a restart I am having a 500 error; the log says:
Any ideas about the reason and hopefully about possible solutions?
Thanks again,
Giovanni
Maybe because the IP address has changed. You can use wildcard to create an user on a specific network range like so:
Thanks, it works!
It’s possible to run it over Kubernetes? Have anybody tried it?
Thank you
I’ve donne the installation (except SSL part as it will running behind a VPN – not configure yet still on local network)… It was working great but after a restart I’ve only a blank page when accessing my IP, all containers running… a bit disappointing and frustrating :/ Any help on this? (I’m actually working on a virtual host before installing it to my physical server)
Hello everyone,
This entire setup has been working like a breeze for about a month; now, right after aa server reboot (intentional and gentle) Nextcloud is working, but Onlyoffice is not. Any ideas? Thanks!
GITHUB REPO ONLYOFFICE FOR NEXTCLOUD (no owncloud)
INSTALL LETS ENCRYPT
FIX NGINX HTTP POLICY FOR NEXTCLOUD
INTEGRATE ONLYOFFICE AND NEXTCLOUD
NOW appear the ONLYOFFICE tab-menu when login to nextcloud server
INTEGRATE ONLYOFFICE AND NEXTCLOUD
RECLAIM SPACE
Hello
I just followed your tutorial and get the error “App “ONLYOFFICE” cannot be installed because it is not compatible with this version of the server.”. I check the App page of Nextcloud and see in red “Server version 10 or lower is required.” and cannot find any update for this app. Is there an issue with Nextcloud 11 and current version of Onlyoffice ?
Or is it a way to bypass this limitation ?
Thanks for helping.
Update : following this https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/37 I downloaded the app manually with –depth=1 :
sudo git clone –depth=1 https://github.com/ONLYOFFICE/onlyoffice-nextcloud.git onlyoffice
And then moved mv onlyoffice/ /var/lib/docker/volumes/docker-onlyoffice-owncloud_app_data/_data/apps/
chowned and it’s now working with the previous version of the app.
I still doesn’t work, somebody have an idea?
Followed the tutorial, and all is working good, thanks!
Anybody able to get pretty url’s working? I’ve tried many methods, but am not able to remove index.php from the url.
Isn’t the “OnlyOffice document server” free for just a 30 day trial?
Or does that only apply to the version installed with deb/packages while the docker installation is free??
I finally found this nice table:
https://github.com/ONLYOFFICE/DocumentServer#onlyoffice-document-server-editions
So yes, there’s a “community edition” that is free and open source.
hello and thanks again for this nice tutorial! Question: the update tool from the web interface is not working. Is there fast and reliable way to update the entire docker container?
Thanks!
Hello,
I didn’t set the HTTPS because my server is in LAN and cannot be accessed from the outside (so far I was never able to validate a certificate …)
Except for that, I installed nextcloud and onlyoffice using these steps.
I don’t get error messages, but after the script, the onlyoffice connector doesn’t work, it says it requires server version 10 minimum.
Nextcloud is version 15 and offers to update to version 16, but it doesn’t seem to have the permissions to do it automaticaly.
There is no option tu update the onyoffice connector from the app interface. If I delete it, I cannot download and install it (because of server version, again).
I’m not sure how to fix that :s
I would very much appreciate if someone had a hint :3
Thank you in advance for your time !
Chris
How can I add a trusted domain in nextcloud, I have loocked for config.php to add it but I couldn’t find it, could you tell me where it is
To get your truested domains:
docker exec -u www-data app-server php occ config:system:get trusted_domains
To set a new one, (eg position 3):
docker exec -u www-data app-server php occ config:system:set trusted_domains 3 –value=thirddomain.com
For those of us not familiar enough with docker/docker-compose, do you think you could make a yaml file that includes the setup of a redis-server container and a mariadb-server container? Also to get a customized nextcloud-data directory to mount? This is what I have so far and it’s not working out.
version: ‘3’
services:
app:
container_name: app-server
image: nextcloud:fpm
stdin_open: true
tty: true
restart: always
expose:
– ’80’
– ‘9000’
volumes:
– app_data:/nextcloud-data/
onlyoffice-document-server:
container_name: onlyoffice-document-server
image: onlyoffice/documentserver:latest
stdin_open: true
tty: true
restart: always
expose:
– ’80’
– ‘443’
volumes:
– document_data:/var/www/onlyoffice/Data
– document_log:/var/log/onlyoffice
nginx:
container_name: nginx-server
image: nginx
stdin_open: true
tty: true
restart: always
ports:
– 80:80
– 443:443
volumes:
– ./nginx.conf:/etc/nginx/nginx.conf
– app_data:/nextcloud-data/
– /etc/letsencrypt:/etc/letsencrypt
redis:
container_name: redis
image: redis
ports:
– 6379:6379
hostname: redis
command: [“redis-server”, “–appendonly”, “yes”]
volumes:
– redis-data:/data
db:
image: mariadb
command: –transaction-isolation=READ-COMMITTED –binlog-format=MIXED –log-bin
restart: always
volumes:
– db:/var/lib/mysql
environment:
– MYSQL_ROOT_PASSWORD=LinuxBabeIsAwesomeness
– MYSQL_PASSWORD=LinuxBabeIsAwesome
– MYSQL_DATABASE=nextcloud
– MYSQL_USER=nextclouduser volumes:
document_data:
document_log:
app_data:
redis-data:
db:
whether the data server must be different from the onlyoffice server?