In the last post, I wrote the way to set up the commento on Ubuntu 20.04 with the binary file. It did works on my VPS. But the problem is very big, it is not updated. The latest binary release is v1.8.0. which is published on April 10, 2020, almost 10 months ago. After that, there is a lot of bug fixed committed on its master branch.

So, I did research to find a way to compile the Commento from the Source.

Let me put it step by step.

Ubuntu 20.04 lts. Nginx web server.

Setting up the environment.

Install the development dependencies.

sudo apt update
sudo apt install build-essential golang go-dep

Install Yarn

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

Check the version

 yarn --version
1.22.5

Yes, my installation is yarn v1.22.5

Optional Go Upgrades

sudo apt install software-properties-common
[[ $(lsb_release -sr) < "18.04" ]] && sudo apt install python-software-properties
# This PPA contains an up-to-date version of Go
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt install golang

I am going to replace the binary Commento with the compiling version. So the Postgresql database is the same one. If you want to do a fresh installation, you should check my previous post for Postgresql installation part.

Compiling Commento

cd /home/davidyin/
$ git clone https://gitlab.com/commento/commento.git
$ cd commento
$ make prod

Now my compiling Commento located at ~/commento/build/prod/

Change the  Service file and Config file.

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

Change the content as below: the ExecStart, and EnvironmentFile

[Unit]
Description=Commento daemon service
After=network.target postgresql.service
 
[Service]
Type=simple
User=commento
Group=commento
ExecStart=/home/davidyin/commento/build/prod/commento
EnvironmentFile=/home/davidyin/commento/build/prod/commento.conf
Environment=
 
[Install]
WantedBy=multi-user.target

Add a new config file.

nano /home/davidyin/commento/build/prod/commento.conf

Add the content below:

# 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.
COMMENTO_ORIGIN=https://comments.yourwebsite.com
## The port to bind the Commento server to. Defaults to 8080.
COMMENTO_PORT=8001
## 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.
#COMMENTO_BIND_ADDRESS=
 
# 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.
#COMMENTO_CONFIG_FILE=/etc/commento.env
 
# 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.
COMMENTO_FORBID_NEW_OWNERS=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.
COMMENTO_STATIC=/home/davidyin/commento/build/prod
 
## If set to true, all static content will be served GZipped if the client's browser supports compression. Defaults to false.
#COMMENTO_GZIP_STATIC=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.
COMMENTO_SMTP_HOST=smtp.email.com
COMMENTO_SMTP_PORT=587
COMMENTO_SMTP_USERNAME=webmaster@yourwebsite.com
COMMENTO_SMTP_PASSWORD=email_password
COMMENTO_SMTP_FROM_ADDRESS=webmaster@yourwebsite.com
 
# Akismet API key
## Create a key in your Akismet dashboard. By default, Akismet integration is turned off when this value is left empty.
#COMMENTO_AKISMET_KEY=
 
# Google OAuth configuration
## Create a new project in the Google developer console (https://console.developers.google.com/project) to generate a set of credentials. By default, Google login is turned off when these values are left empty.
#COMMENTO_GOOGLE_KEY=
#COMMENTO_GOOGLE_SECRET=
 
# GitHub OAuth configuration
## Create a new OAuth app in GitHub developer settings (https://github.com/settings/developers) to generate a set of credentials. By default, GitHub login is turned off when these values are left empty.
#COMMENTO_GITHUB_KEY=
#COMMENTO_GITHUB_SECRET=
 
# Gitlab OAuth configuration
## Create a new application in your GitLab settings (https://gitlab.com/profile/applications) to generate a set of credentials. By default, GitLab login is turned off when these values are left empty.
#COMMENTO_GITLAB_KEY=
#COMMENTO_GITLAB_SECRET=
 
# Twitter OAuth configuration
## Create an app in the Twitter developer dashboard (https://developer.twitter.com/en/apps) to generate a set of credentials. By default, Twitter login is turned off when these values are left empty.
#COMMENTO_TWITTER_KEY=
#COMMENTO_TWITTER_SECRET=

Restart Commento

sudo systemctl restart commento

Now it is the latest version. Most important is the Twitter account avatar link is fixed.

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

Leave a Reply

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