Setup the Commento on Ubuntu 20.04

Commento is an open-source platform. It is a comment system for blogs. I like its slogan.: Embed comments without giving up your privacy.

You can use the commento service at by paying $10 a month. Or you can set up your own commento system on your own server.

I choose the second one. Here is How I set up my commento on a Ubuntu 20.04 server.

On the Commento docs you can find the official guide of self-hosting. I just recorded my own steps.

I have the Ubuntu 20.04 with the Nginx server already.

Install Postgresql Server

sudo apt install postgresql -y

Prepare the Database and the user of database

I use the database name commento, and the user name commento, password is yourown_password, you should use your own password.

sudo -i -u postgres psql -c "CREATE DATABASE commento;"
sudo -i -u postgres psql -c "CREATE USER commento WITH PASSWORD 'yourown_password';"
sudo -i -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE commento TO comment;"

Add a Ubuntu user

sudo adduser \
--system \
--shell /bin/bash \
--gecos 'Commento' \
--group \
--disabled-password \
--home /home/commento \

Prepare the directory and download the latest binary version.

sudo mkdir -p /opt/commento/assets

sudo rm -rf /opt/commento/assets/*

sudo mv commento-v1.8.0-linux-glibc-amd64.tar.gz /opt/commento/assets
cd /opt/commento/assets
sudo tar xf commento-*.tar.gz
sudo rm commento-*.tar.gz
sudo mv commento ../
sudo chown -R commento:commento /opt/commento

Add the system service file and give the path of the commento config file.

sudo nano /etc/systemd/system/commento.service

Add the following into the file, save, exit.

Description=Commento daemon service postgresql.service



Add a config file

sudo mkdir /etc/commento/
sudo nano /etc/commento/commento.conf 

Add the content below into the file, save, exit.

Use your own website to replace the

Use the password of the database user to replace the yourown_password

SMTP setting is very important, you should use your own email server. You can not confirm the new user signup without the SMTP settings.

# Commento

# Network settings
## This should be set to the subdomain or the IP address hosting Commento. All API requests will go to this server. This may include subdirectories if Commento is hosted behind a reverse proxy, for example. Include the protocol in the value to use HTTP/HTTPS.
## The port to bind the Commento server to. Defaults to 8080.
## The address to bind the Commento server to. Useful if the server has multiple network interfaces. If not specified, this value defaults to COMMENTO_ORIGIN.

# Database settings
COMMENTO_POSTGRES="user=commento password=yourown_password host=/var/run/postgresql/ port=5432 dbname=commento sslmode=disable"

# Configuration file
## A configuration file for Commento. Useful to store secrets and credentials. No config file will be loaded by default, if left unspecified.

# Forbid registration of new users
## Used to disable new dashboard registrations. Useful if you are the only person using Commento on your server. Does not impact the creation of accounts for your readers. Defaults to false.

# Static files settings
## If you want to store the binary in a different directory from the static assets, set this directory to point to the static assets (HTML, JS, CSS, email templates and database migrations). Defaults to the same directory as the binary.

## If set to true, all static content will be served GZipped if the client's browser supports compression. Defaults to false.

# SMTP settings
## SMTP credentials and configuration the server should use to send emails. By default, all settings are empty and email features such as email notification and reset password are turned off.

# Akismet API key
## Create a key in your Akismet dashboard. By default, Akismet integration is turned off when this value is left empty.

# Google OAuth configuration
## Create a new project in the Google developer console ( to generate a set of credentials. By default, Google login is turned off when these values are left empty.

# GitHub OAuth configuration
## Create a new OAuth app in GitHub developer settings ( to generate a set of credentials. By default, GitHub login is turned off when these values are left empty.

# Gitlab OAuth configuration
## Create a new application in your GitLab settings ( to generate a set of credentials. By default, GitLab login is turned off when these values are left empty.

# Twitter OAuth configuration
## Create an app in the Twitter developer dashboard ( to generate a set of credentials. By default, Twitter login is turned off when these values are left empty.

Add a new Nginx config file for this new server.

sudo nano /etc/nginx/conf.d/comments.conf 

Add the content below into the file.

server {
listen 80;

location /.well-known/acme-challenge/ {
root /var/www/acme;

location / {
return 301 https://$host$request_uri;

server {
listen 443 ssl http2;

ssl_certificate /etc/letsencrypt/live/;
ssl_certificate_key /etc/letsencrypt/live/;
ssl_dhparam /home/davidyin/ssl/dhparam.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
resolver valid=300s;
resolver_timeout 5s;
add_header X-Content-Type-Options nosniff;
add_header Strict-Transport-Security "max-age=63072000; preload";
keepalive_timeout 300s;

location ~ ^/(css/commento.css|js/commento.js)$ {
# the css and js file can be cached
expires modified 365d;
proxy_pass http://localhost:8001;

location ~ ^/(api/(commenter|comment|page|oauth))/ {
proxy_pass http://localhost:8001;

location / {
satisfy any;
proxy_pass http://localhost:8001;

Install Certbot to get the new SSL certificate.

sudo systemctl stop nginx
sudo apt install certbot
sudo certbot certonly --standalone --rsa-key-size 4096 -d
sudo systemctl start nginx
sudo systemctl restart commento


Sign Up your  first user.


You can add a new user, check your email and confirm the email address.

Then you can sign in the system and add a new site. Get the script snipper, add it into your blog template.



Leave a Reply

Your email address will not be published. Required fields are marked *