How to Install ONLYOFFICE Document Server with Nginx on Debian 10
In this tutorial, we will show you how to install the Onlyoffcie Document Server on the latest Debian Buster 10. We will install the Onlyoffice Document Server with the PostgreSQL, Nginx, and Letsencrypt.
To install the Onlyoffice Document Server, at least, you need the Debian server with 2GB of RAM, 4GB SWAP, 2 CPUs, and 40GB of free disk space.
What we will do:
- Install Packages Dependencies
- Install and Configure PostgreSQL
- Generate SSL Letsencrypt and DHPARAM
- Install Onlyoffice Document Server
- Running Onlyoffice Document Server with HTTPS
Step 1 - Install Packages Dependencies
In this first step, we will install some packages dependencies needed by the Document Server, including the RabbitMQ-server, Redis, and Nginx-extras.
Update your Debian system repository and install Document Server packages dependencies using the apt command below.
sudo apt update
sudo apt install redis-server rabbitmq-server nginx-extras gnupg2
Once all installation is complete, check the following services using the systemctl command as below.
systemctl is-enabled nginx
systemctl is-enabled rabbitmq-server
systemctl is-enabled redis-server
Now make sure all of these services are enabled and will automatically run on the system boot.
Step 2 - Install and Configure PostgreSQL Database
In this step, we will install the PostgreSQL database to the Debian Buster 10 and create a new database and user the Onlyoffice Document Server.
Now install the PostgreSQL database using the apt command below.
sudo apt install postgresql
Once the installation is complete, start the PostgreSQL service and add it to the system boot.
systemctl start postgresql
systemctl enable postgresql
As a result, the PostgreSQL database is up and running on the Debian server.
Next, we will create a new database and role for the Document Server installation.
Log in to the PostgreSQL shell using the command below.
sudo -i -u postgres psql
Create a new database and user named 'onlyoffice' with the password 'onlyoffice' using the PostgreSQL queries below.
CREATE DATABASE onlyoffice;
CREATE USER onlyoffice WITH password 'onlyoffice';
GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;
As a result, the PostgreSQL database for the Onlyoffice Document Server has been created.
Step 3 - Generate SSL Letsencrypt and DHPARAM
For this tutorial, we will run the Document Server on the secure HTTPS protocol, and we will generate new SSL certificates from lets encrypt and generate the DHPARAM certificate.
Install the Certbot tool for generating SSL Letsencrypt certificates using the apt command below.
sudo apt install certbot
Next, generate new SSL certificates using certbot command below, and make sure to change the domain name and the email address with your own.
certbot certonly --standalone --agree-tos -m [email protected] -d onlyoffice.hakase-labs.io
Once the certbot command is completed, your SSL certificates will be located at the '/etc/letsencrypt/live/onlyoffice.yourhakase-labs.io' directory.
And you've successfully generated SSL Letsencrypt using the certbot command-line tool.
Next, we will generate the DHPARAM certificate using the openssl binary command.
Go to the '/etc/ssl/certs' directory and generate the DHPARAM certificate using the openssl command below.
openssl dhparam -out dhparam.pem 4096
And your DHPARAM certificate is located at the '/etc/ssl/certs' directory.
As a result, you've generated SSL Letsencrypt and DHPARAM for the Document Server.
Step 4 - Install ONLYOFFICE Document Server
In this step, we will install the Onlyoffice Document Server. Although the available repository is for Debian Squeeze, it's working on the latest Debian Buster 10.
First, add the GPG key of the Onlyoffice Document Server to your Debian system.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
Now add the Document Server repository.
sudo echo "deb https://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list
After that, update Debian repository lists and install the Onlyoffice Document Server using the apt command below.
sudo apt update
sudo apt install onlyoffice-documentserver
During the installation, you will be asked about the PostgreSQL database password for the Document Server, type the 'onlyoffice' database password and choose 'OK' to continue.
And the Onlyoffice Document Server installation will be completed. It's running on the default HTTP port 80, accessible through the web browser.
Step 5 - Running Document Server on HTTPS
In this step, we will secure the Document Server installation with the HTTPS protocol and using the SSL Letsencrypt and dhparam.
By default, the Document Server provided its virtual host configuration for the Nginx web server, located at the '/etc/onlyoffice/documentserver/nginx/' directory.
First, stop the Nginx service using the systemctl command below.
systemctl stop nginx
Now go to the '/etc/onlyoffice/documentserver/nginx/' directory and copy the virtualhost template configuration for the Document Server for SSL 'ds-ssl.conf.tmpl' to the 'ds.conf'.
cp ds-ssl.conf.tmpl ds.conf
Now edit the Document Server configuration 'ds.conf' using vim editor.
On the ssl_certificate and ssl_certificate_key options, change the path with your SSL certificates path.
Uncomment the ssl_dhparam option and change the path of the DHPARAM certificate with your own.
Save and close.
Next, test the Nginx configuration and make sure there is no error, then start the Nginx service.
systemctl restart nginx
As a result, the Document Server is no running on the HTTPS secure connection with the SSL from Letsencrypt.
Step 6 - Testing
Open your web browser and type the domain of your Onlyoffice Document Server installation on the address bar. Mine is:
Now you will get page says that the Onlyoffice Document Server is up and running as below.
As a result, the installation of Onlyoffice Document Server with the PostgreSQL and Nginx webserver on the Debian Buster 10 has been completed successfully.