Arvutiteadus
Published in

Arvutiteadus

FOSS document editing in Nextcloud

Microsoft Office was great, however we had to pay for it or use a pirate version. OpenOffice was great, too, however LibreOffice version of it had the source code open. And then, Google Drive came into appearance and made it possible to edit documents online. Their source code isn’t open. So I moved to Nextcloud and installed it on my own server. On that, I use a FOSS version of Microsoft Office that’s called ONLYOFFICE. Developed by Latvian Russians, that suite brings it all together that I need: the software is free, open-source, runnable on my own server and the user interface is user-friendly. I can’t do some things on it like I used to do with Kami in Google Drive but I hope to find an alternative for that, too. So, how in our holy green world did I set up ONLYOFFICE on my server?

I can’t remember how I did it. It run months before I had to restart the server machine. After that, I couldn’t open any files with ONLYOFFICE. Why? Because something did not come up automatically. As I don’t remember the installing process, I write down some important things that I remember.

I assume that Nextcloud is installed already.

I really don’t recommend to use either apt nor snap for installing ONLYOFFICE because it can screw up the whole system. The apt version demands removing mariadb and replace it by mysql which isn’t my way of doing things. Although both females seem to be nice, I haven’t met them, maria is more important as she’s opener. I wouldn’t give up on maria. The snap version creates a daemon that restarts nginx every time I kill it and can’t even run ONLYOFFICE. So I did the install manually.

I followed an official manual and decided to install ONLYOFFICE into docker using external storage and nginx as the reverse proxy. I also configured it with certbot for using HTTPS.

There’s another official manual that explaines other stuff that we need for ONLYOFFICE. I needed to set up mysql in docker:

As the port 3306 is in use for mariadb, I needed another free port for mysql.

My command for creating a container for the document server:

As I want to run other sites served by nginx on the same machine and port as ONLYOFFICE, I need to make ONLYOFFICE run on a different port. In my example, docker’s port 5 will be directed to the host port 443.

I also needed to set up rabbitmq-server outside docker. So, inside docker, only two things run: onlyoffice-mysql-server and onlyoffice-document-server.

nginx reads the content of conf.d folder that has ds.conf which links to other configuration files of ONLYOFFICE that reside in /etc/onlyoffice/. I also had to create a dedicated domain for the document server.

Once ONLYOFFICE’s document server is running properly, I can call its dedicated domain and see the confirmation.
For connecting the document server to “Nextcloud”, we do the set up in the settings after installing the corresponding app.

Once, my home had a power failure and the server machine performed a restart. After that, I couldn’t use ONLYOFFICE anymore. It looked like the particular container wasn’t running. So I started the container and could enjoy ONLYOFFICE again.

A couple of days later, my had suffered another power failure. This time, the upper solution didn’t work. I saw the container running but ONLYOFFICE in Nextcloud kept showing the animated ONLYOFFICE logo. I couldn’t access the document server directly neither (172.18.0.1 appeared to be the Internet Protocol address of my docker container):

I wanted to confirm the correct port forwarding:

So port 5 in the host computer was forwarded correctly to port 443 of the container. I tried to access the port 5:

Restarting docker didn’t made anything better. I tested with the domain name:

As it was obvious that the problem resides inside the container, I wanted to see the contents of the document server log file:

and the contents of the corresponding nginx file:

So I decided to reinstall the docker version (official documentation):

docker-compose.yml              100%[=======================================================>]   3,07K  --.-KB/s    in 0s2020-07-28 02:42:54 (23,9 MB/s) - ‘docker-compose.yml’ saved [3144/3144]

sudo docker-compose up -d ended with error messages complaining about name conflicts. So I stopped and renamed the old containers. Next, I had to change all the port forwarding in docker-compose.yml for some free ports in the host computer. Finally, I took like forever and after forever, I got this error message:

I changed the timeout value to 120 by exporting the variables:

I restarted docker which took another forever. It didn’t change a shit as I got another error message that the timeout was still 60.

Then, I found another manual how to install ONLYOFFICE with snap. But wait, didn’t I write before that snap screwed up my website configurations? Well, it did and it also did this time kind of but I found a way to direct ONLYOFFICE into a different port:

I also had to create the security certificate:

Now, only one problem remains: ONLYOFFICE currently runs on two ports: 80 and 270. This means that if node that servers ONLYOFFICE would start before nginx next time my home would suffer a power failure and nginx cry to death as its port 80 would be in use already. In order to avoid that sad emotion for nginx, I had to set the snap version of ONLYOFFICE to use the port 271 instead of 80:

I’m not sure whether I could avoid the named port overlapping problem by that as although port 271 really responds with ONLYOFFICE stuff but 80 also still does that. Oh no, this is because 80 is still served from inside docker. And now, snap also tries to use 80. Once a day, I have to rerun the last command because then, snap does a restart to its nginx and frees the port 80 for the docker version. Probably, the community server failed and not document server during the install. It’s strange that in snap, I can’t see that its ONLYOFFICE is configured to run on port 271 although it still runs on that port. I stopped the snap container, so still, the docker version serves me hopefully fine.

It turned out that stopping isn’t enough, maybe disabling is.

Every day, I had to spend hours for figuring out why once again, ONLYOFFICE didn’t work. I did things without real knowledge. I turned out that docker didn’t have that ONLYOFFICE I was using. My ONLYOFFICE was installed probably using a DEB-file sitting in /var/www/onlyoffice.

I started over in a laptop that hadn’t ONLYOFFICE before. That laptop has Ubuntu 20.04.

I downloaded the fresh six days old DEB-file from the repository and tried to install it:

dpkg: error processing package onlyoffice-documentserver (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
onlyoffice-documentserver

I was surprised that this community version has a support for mariadb. I had lots of dependency problems, so I decided to give them a go starting by mariadb:

I couldn’t install it because of previous problems, so I did sudo apt --fix-broken install which removed mariadb without asking. What a prick! In addition it complained:

Obviously apt installed onlyoffice-documentserver and now, I wanted to get rid of it:

I went right away and reinstalled mariadb: sudo apt install mariadb-server . Then, I tried to reinstall the DEB-package with the same errors as previously because the system was missing lots of dependencies. I did the same mistake again by trying to reinstall mariadb-client and went through fixing and purging and reinstalling mariadb-server again. And then:

E: Package 'onlyoffice-documentserver' has no installation candidate

Of course not, because officially, it’s not part of Ubuntu.

This time, I didn’t want to remake my performed mistake and started to install the dependencies one by one:

peacecop@peacecop-HP-ProBook-4520s:~/Allalaadimised$ sudo apt install postgresql-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
postgresql-client-12 postgresql-client-common
Suggested packages:
postgresql-12 postgresql-doc-12
The following NEW packages will be installed:
postgresql-client postgresql-client-12 postgresql-client-common
0 upgraded, 3 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/1 074 kB of archives.
After this operation, 3 998 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Selecting previously unselected package postgresql-client-common.
(Reading database ... 343263 files and directories currently installed.)
Preparing to unpack .../postgresql-client-common_214_all.deb ...
Unpacking postgresql-client-common (214) ...
Selecting previously unselected package postgresql-client-12.
Preparing to unpack .../postgresql-client-12_12.2-4_amd64.deb ...
Unpacking postgresql-client-12 (12.2-4) ...
Selecting previously unselected package postgresql-client.
Preparing to unpack .../postgresql-client_12+214_all.deb ...
Unpacking postgresql-client (12+214) ...
Setting up postgresql-client-common (214) ...
Setting up postgresql-client-12 (12.2-4) ...
update-alternatives: using /usr/share/postgresql/12/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-client (12+214) ...
Processing triggers for man-db (2.9.1-1) ...
peacecop@peacecop-HP-ProBook-4520s:~/Allalaadimised$ sudo apt install pwgen
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
pwgen
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/18,1 kB of archives.
After this operation, 52,2 kB of additional disk space will be used.
Selecting previously unselected package pwgen.
(Reading database ... 343550 files and directories currently installed.)
Preparing to unpack .../pwgen_2.08-2_amd64.deb ...
Unpacking pwgen (2.08-2) ...
Setting up pwgen (2.08-2) ...
Processing triggers for man-db (2.9.1-1) ...
peacecop@peacecop-HP-ProBook-4520s:~/Allalaadimised$ sudo apt install supervisor
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
supervisor-doc
The following NEW packages will be installed:
supervisor
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/281 kB of archives.
After this operation, 1 682 kB of additional disk space will be used.
Selecting previously unselected package supervisor.
(Reading database ... 343555 files and directories currently installed.)
Preparing to unpack .../supervisor_4.1.0-1ubuntu1_all.deb ...
Unpacking supervisor (4.1.0-1ubuntu1) ...
Setting up supervisor (4.1.0-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for systemd (245.4-4ubuntu3.2) ...

As sudo netstat -plunt | grep :543 answered with emptyness, I had to install postgresql, too and after that, postgresql was running:

Could I install the DEB file now? Let’s see:

There was no postgresql database present, so I had to create it with the credentials:

peacecop@peacecop-HP-ProBook-4520s:~/Allalaadimised$ sudo -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
CREATE ROLE
peacecop@peacecop-HP-ProBook-4520s:~/Allalaadimised$ sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"
GRANT

Fine, the database with correct credentials was there. Did the DEB-install succeed this time? Let’s find out:

Well, previously, as I made gave my first try for that DEB-file, I was asked for the password and I entered my own password. I could remember it via sudo DEBCONF_DEBUG=developer dpkg --configure onlyoffice-documentserver which showed me that under debconf (developer): <-- GET onlyoffice/db-pwd . So I had to alter the password for the user in the database with ALTER USER onlyoffice WITH password '

Was the DEB-install a success after this? Let’s find out:

Yey! It says: successfully! However, accessing localhost via web browser resulted with Bad request. So I went to see the logs: cd /var/log/onlyoffice/documentserver . I wanted to see which log file I needed:

It was nginx.error.log:

It says that port 8000 is unoccupied and sudo netstate -plunt | grep :8000 confirms that. I thought that I had to bring the service up somehow using nodejs but memorized that some more dependencies were needed: rabbitmq-server and redis-server. I installed them and confirmed that these services were up and running:

aug   04 00:24:47 peacecop-HP-ProBook-4520s systemd[1]: Starting RabbitMQ Messaging Server...
aug 04 00:24:53 peacecop-HP-ProBook-4520s systemd[1]: rabbitmq-server.service: Supervising process 149269 which is not our child. We'll mos>
aug 04 00:24:53 peacecop-HP-ProBook-4520s systemd[1]: Started RabbitMQ Messaging Server.
aug 04 00:25:01 peacecop-HP-ProBook-4520s systemd[1]: rabbitmq-server.service: Supervising process 149269 which is not our child. We'll mos>
aug 04 00:25:20 peacecop-HP-ProBook-4520s systemd[1]: rabbitmq-server.service: Supervising process 149269 which is not our child. We'll mos>
aug 04 00:25:21 peacecop-HP-ProBook-4520s systemd[1]: rabbitmq-server.service: Supervising process 149269 which is not our child. We'll mos>
aug 04 00:25:21 peacecop-HP-ProBook-4520s systemd[1]: rabbitmq-server.service: Supervising process 149269 which is not our child. We'll mos>
aug 04 00:25:22 peacecop-HP-ProBook-4520s systemd[1]: rabbitmq-server.service: Supervising process 149269 which is not our child. We'll mos>
aug 04 00:25:23 peacecop-HP-ProBook-4520s systemd[1]: rabbitmq-server.service: Supervising process 149269 which is not our child. We'll mos>
peacecop@peacecop-HP-ProBook-4520s:/var/www/onlyoffice/documentserver/npm$ sudo systemctl status redis-server.service
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-08-04 00:25:22 EEST; 1min 7s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 151482 (redis-server)
Tasks: 4 (limit: 9286)
Memory: 2.3M
CGroup: /system.slice/redis-server.service
└─151482 /usr/bin/redis-server 127.0.0.1:6379
aug 04 00:25:22 peacecop-HP-ProBook-4520s systemd[1]: Starting Advanced key-value store...
aug 04 00:25:22 peacecop-HP-ProBook-4520s systemd[1]: redis-server.service: Can't open PID file /run/redis/redis-server.pid (yet?) after st>
aug 04 00:25:22 peacecop-HP-ProBook-4520s systemd[1]: Started Advanced key-value store.

I also checked their ports:

peacecop@peacecop-HP-ProBook-4520s:/var/www/onlyoffice/documentserver/npm$ sudo netstat -plunt |grep :6379
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 151482/redis-server
tcp6 0 0 ::1:6379 :::* LISTEN 151482/redis-server

And now, suddenly, port 8000 was occupied as well:

What is the process 146639 exactly:

It seems that ONLYOFFICE runs without nodejs this time.

Anyway, I copied the DEB-file to the main server machine:

I also wanted to confirm that I had the latest version 5.6:

I also gave another shot to the community server. I must tell you that if your time is important for you, forget the community server! Nextcloud is just everything you need for a web file management system and other apps. It took more than an hour to bring up the community server inside docker. During that time the whole laptop with 8 GB RAM was frozen. After that, I could load it in web browser, create an administrator user and start using it. It looked very promising: project management and everything inside! But all that shit doesn’t matter if the system is slow as snail and overloads the computer.

Last bat not least, I tested out the collaboration. For that, I connected the community server to my Nextcloud and opened the same file in both file management systems. During that process, many times one or the other browser tab crashed. I could still do some changes in Nextcloud and see those changes in the community server, however they appeared first after closing and reopening the file, not on the fly as they were supposed to appear.

Then, I opened the same file in Nextcloud in two laptops. I saw my changes in either of them in real time. I could comment and chat. On the same time, community server didn’t show shit. I also tried to log in on the other laptop at the same time and the logging in process kept going without an end.

So if you want to switch from Google Drive to Nextcloud and ONLYOFFICE document server, you would survive some schocking experiences and not the positive way. Whatsoever, Nextcloud and ONLYOFFICE document server are FOSS and this is the only thing that thrives me in this direction.

I would not install the community server to the main server machine with only 4 GB RAM. The community server is like an externally super attractive human of the opposite sex but if I let them close to me they eat me alive. So I rather go out and in with somebody whose body vehicle isn’t that beautiful but who cares of me.

I also want to add this long story that after the last change of the document server in the main server machine, I was very upset as none of the files in Nextcloud had my changes made during the last three days. I only could restore the changes because I still had these files open in one of the laptops. I had to create new files and manually copy and paste the contents of all the worksheets. This means that the databases are still in use for changes. I also want to figure out why are there two databases needed for that.

Until there is no better FOSS document editing collaboration web-based system available, ONLYOFFICE is the best. It’s not good, far from that but it’s the best what we have.

Meanwhile, I had discussions with some developers of ONLYOFFICE and got some answers. There’s an upgrade guide and an API guide.

A new problem is that the ONLYOFFICE isn’t server if RabbitMQ doesn’t work. Sometimes, it just stops working and restarting doesn’t help — it just keeps activating. Once, there were some intruders detected, once the disk filled up. In the first case, RabbitMQ started to work after a day or so. This time, I didn’t dare to wait, purged and reinstalled it and now, it works again. I didn’t notice any data loss. As this happened again after restarting the server machine, I reported this as a bug on 20210115.

This is why I followed the suggestions of ShockwaveNN and turned off all the onlyoffice-stuff in supervisor. Afterwards, in order to get ONLYOFFICE running, I turned them on again by issuing:

He also suggested to report to rabbitmq’s developers which I did.

It turned out that rabbitmq-server can’t connect to the node test because it couldn’t find where test is. This is weird because why it did find it after a reinstall? So what I did was setting test to lead to 127.0.0.1 in hosts. Now, everything works just fine. I did it because of a suggestion at Programmersought. This all happened to and with me on 20210120.

20201019: I discovered that the function SUMIFS didn’t work, so I reported the issue following by upgrading the document server making the function work again.

For version info, I opened another issue.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
peacecop kalmer:

I teach math, computer science and tennis, create software, arrange tennis events, process multimedia, run orienteering, collect tree juices and fruits.