So you have installed VestaCP and everything is going great, you even installed Nextcloud and you are now trying to install Onlyoffice Document Server with VestaCP but are not having any luck. If that sounds familiar it is because I tried to do the same thing. But every time I would search the web for a solution there wasn’t really anything guide I could follow specifically to get it working with VestaCP.
Whenever I would try to install OnlyOffice alongside VestaCP things would not go smoothly and I would always have to restore my VPS from a backup. For a while, I did what anyone would do and just settled for running OnlyOffice on a separate VPS. But come on! that’s just a waste of money, having a separate VPS for something you don’t even use all the time. So finally I decided to get to it, dive deep into the code base, and find a solution.
You will need three things:
- Docker
- A Sub-Domain
- Custom VestaCP template (and of course VestaCP)
The installation process is relatively easy, first, you install Docker on your system, then you run the docker script for OnlyOffice, followed by connecting the sub-domain you want to park OnlyOffice to. That’s about it and you are good to go. That is literally how you install Onlyoffice Document Server with VestaCP, simple and without a fuss. So now let’s go through it step by step.
Install Docker
Installing Docker Community edition is simple and requires you to enter the respective install commands on your system.
Ubuntu
If you are using Ubuntu you will have to utilize the APT command to install Docker. Before you do so please make sure you update your system to the latest packages to avoid any potential complications.
sudo apt update && sudo apt upgrade -y
The docker engine does not come in the default repositories on Ubuntu so to install docker we will first have to set up the official docker repositories. Only then can we begin installing Docker on our system.
The Docker Repositories use HTTPS so we will need to install some packages to allow APT to function over HTTPS:
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
Next we are going to add the official GPG key for the Docker repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Now the follow command will set up the official stable Docker repository:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Moving on its time to install the Docker engine, as per best practice we will update the system repositories beforehand:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
Once the installation has completed let us verify that the docker engine has installed successfully:
sudo docker run hello-world
If everything has gone correctly you should get the following output:
onlyoffice@localhost:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:49a1c8800c94df04e9658809b006fd8a686cab8028d33cfba2cc049724254202
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
On Ubuntu to show the list of running dockers you can use the command below:
sudo docker container ls
For now, the command should return an empty list as nothing is currently running.
Congratulations you have successfully installed docker on your Ubuntu Installation. In the next step, we shall get the OnlyOffice Docker up and running.
CentOS
If you are going with CentOS we shall be using a slightly different variation of commands. Contrary to the APT package manager, CentOS will need you to use the YUM package manager.
Before you do anything please make sure you update your system to the latest packages to avoid any potential complications.
sudo yum update -y
Just like ubuntu, the docker engine does not come in the default repositories so to install docker we will first have to set up the official docker repositories. Only then can we begin installing Docker on our system.
You will need the package yum-utils
which will provide the yum-config-manager
, a utility that will allow you to add the repository we will be needing to install Docker.
sudo yum install -y yum-utils
Now the follow command will set up the official stable Docker repository:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Moving on its time to install the Docker engine, as per best practice we will update the system repositories beforehand:
sudo yum update -y
sudo yum install docker-ce docker-ce-cli containerd.io -y
If you face any issue regarding containerd.io and get the following error message as I did when I tried to install Docker on CentOS 8 you will need to install containerd.io manually as per the solution provided by vExpose:
Error:
Problem: package docker-ce-3:19.03.12-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
- cannot install the best candidate for the job
- package containerd.io-1.2.10-3.2.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.2.13-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.2.13-3.2.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.2.2-3.3.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.2.2-3.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.2.4-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.2.5-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.2.6-3.3.el7.x86_64 is filtered out by modular filtering
To manually install the containard.io package use the following command listed below:
sudo yum install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
Then try once again to install the Docker packages, this time omitting the containard.io package:
sudo yum install docker-ce docker-ce-cli -y
Once the installation has completed we will need to start the Docker service:
sudo systemctl start docker
sudo systemctl enable docker
Now let us verify that the docker engine has installed successfully:
sudo docker run hello-world
If everything has gone correctly you should get the following output:
[onlyoffice@li1758-184 ~]$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:49a1c8800c94df04e9658809b006fd8a686cab8028d33cfba2cc049724254202
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
On CentOS to show the list of running dockers you can use the command below:
sudo docker container ls
For now, the command should return an empty list as nothing is currently running.
Congratulations you have successfully installed docker on your Ubuntu Installation. In the next step, we shall get the OnlyOffice Docker up and running.
Install OnlyOffice Document Server with VestaCP
Now that we have got the Docker engine installed and running properly, its time to set up the OnlyOffice Document Server. Below are the minimum system requirements set out in the official documentation although I’m sure you could try to get by with less.
System Requirements
- CPU dual-core 2 GHz or better
- RAM 2 GB or more
- HDD at least 40 GB of free space
- Additional requirements at least 4 GB of swap
- OS amd64 Linux distribution with kernel version 3.10 or later
- Additional requirements
- Docker: version 1.10 or later
Moving forward there are two ways to set up the docker. You can set it up with storage inside the containers or with storage outside the containers. Naturally you want your storage to have persistence and you will want to set it up like I did with the data outside of the container.
The data are stored in their own specific directories which we will map to within the docker container itself:
/var/log/onlyoffice
Document Server logs/var/www/onlyoffice/Data
certificates/var/lib/onlyoffice
file cache/var/lib/postgresql
database
Since we will be using Nginx as a reverse proxy we won’t be setting up the docker to run using HTTPS. Now using the template I have set up below which is set up to connect using the port 8181 we will map the custom port to the local container HTTP port of 80. The code is below; if you would like to change the port mapping remember to change them in the VestaCP template as well:
sudo docker run -i -t -d -p 8181:80 --restart=always \
-v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice \
-v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data \
-v /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \
-v /app/onlyoffice/DocumentServer/db:/var/lib/postgresql onlyoffice/documentserver
The Docker engine should now begin to pull the container from the official Docker Hub. This should take a few minutes if you are running this for the first time. You should the following output if you are running it for the first time:
Unable to find image 'onlyoffice/documentserver:latest' locally
latest: Pulling from onlyoffice/documentserver
23884877105a: Pull complete
bc38caa0f5b9: Pull complete
2910811b6c42: Pull complete
36505266dcc6: Pull complete
73f11410c785: Pull complete
0b794493f513: Pull complete
633e8270f79c: Pull complete
6d05fcc39b66: Pull complete
Digest: sha256:4e667e43243e283c72700420b5a6111506469403d06c52b6d458129837a8737f
Status: Downloaded newer image for onlyoffice/documentserver:latest
088e53408e8c6badb8525db815bd1eec0bf6ea8fafa86b1ef188260a4f648b52

The container is set to automatically restart if it is ever stopped. If you would like to manually stop it you can do so with the command below:
sudo docker stop container_name
The name of your container will be the last entry on your right when you run the following command to list running docker containers:
sudo docker container ls
If you would like to run the container again just rerun the original command you used to run the container.
Install VestaCP custom template
Now that you have installed OnlyOffice Document Server, you can move on to the next step. Since you probably want a secure connection to it via HTTPS, we will need to generate an SSL certificate and connect it to a domain. You don’t want any of the hassles of a self-signed certificate.
We shall let VestaCP handle all of it, but how you ask? By using VestaCP Nginx templates. To do so we will need a special custom code to properly be able to run the document server.
There are two ways you can do this, the easy way or the manual way which requires a few more steps.
First enter into the Nginx folder that is located within the VestaCP templates folder:
cd /usr/local/vesta/data/templates/web/nginx
Download the template files
Download and unzip the template files to your VestaCP Nginx templates folder:
sudo wget -4 https://zedpro.me/vestacp/templates/onlyoffice.zip
sudo unzip onlyoffice.zip
Manually Writing the template files
If you would like to manually create those files, you can copy and paste the template code below. You can even modify the code to better suit your needs. You will need to create two files in the Nginx template folder;
Below is the custom code for the respective Nginx templates will all the necessary configurations to securely reverse proxy the OnlyOffice Document Server Docker container to your chosen subdomain:
.tpl file
server {
listen %ip%:%proxy_port%;
server_name %domain_idn% %alias_idn%;
location / {
rewrite ^(.*) https://%domain_idn%$1 permanent;
}
include %home%/%user%/conf/web/*nginx.%domain_idn%.conf_letsencrypt;
}
.stpl file
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 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;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
server {
listen %ip%:%proxy_ssl_port% http2;
server_name %domain_idn% %alias_idn%;
ssl on;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
ssl_verify_client off;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
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;
location / {
proxy_pass http://localhost:8181;
proxy_http_version 1.1;
location ~* ^.+\.(%proxy_extentions%)$ {
root %sdocroot%;
access_log /var/log/%web_system%/domains/%domain%.log combined;
access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location @fallback {
proxy_pass http://localhost:8181;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include %home%/%user%/conf/web/*nginx.%domain_idn%.conf_letsencrypt;
include %home%/%user%/conf/web/s%proxy_system%.%domain%.conf*;
}
Now that you have installed the templates you will need to go into your VestaCP control panel and change the sub-domain you want the OnlyOffice Document server running on to use the new template that you have installed.
