I recently upgraded this blog to Ghost 2.x and took the opportunity to abandon Disqus. It bloated the post page and came with something like 45 tracking scripts/cookies. To replace it I settled on Commento, a small and privacy-focused open source solution. The minimum subscription is $3/month, which is a bit high for a blog that I only pay $5/month for. Luckily they offer a self-hosted option. Here is how I got it setup.
Since I am running this blog on Digital Ocean I chose to install and run Commento from the same Droplet (Virtual Machine). You don't need to do this, but the smallest Droplet is sufficient to run Ghost and Commento side-by-side if your traffic isn't too high.
Prerequisites
PostgreSQL: This is a requirement. This is a good guide for installation. Commento requires its own database. I created a system user named "commento" (adduser commento), matched it to a databse role (createuser --interactive, name it "commento") and a database of the same name (createdb commento). When you are done make sure you sudo systemctl enable postgresql to keep it running.
smtp: This is optional, but without it you wont be able to send activation or password reset emails. While its focused on gmail forwarding, my mailgun guide covers setting up smpt credentials which will be usable for Commento. I highly recommend getting this setup.
DNS: Commento needs its own (sub)domain to run on. I used commento.blog.kye.dev, and pointed it to the same floating IP that Ghost is on.
Install Commento
# Switch to the commento usersudo-u commento
# Downloadwget https://commento-release.s3.amazonaws.com/commento-linux-amd64-v1.7.0.tar.gz
# Unpackmkdir commento-server
tar xvf commento-linux-amd64-v1.7.0.tar.gz -C ./commento-server
# Switch usersudo-u ghost-mgr
# Navigate to ghost install rootcd /var/www/ghost
# Set Commento URL
ghost config url https://commento.YOURBLOG.com
# Get Ghost-CLI to generate an SSL setup for you:
ghost setup nginx ssl
# Switch back to your Blog
ghost config url https://YOURBLOG.com
This will create certs with Lets Encrypt/acme.sh, as well as generate some NGINX conf files in /var/www/ghost/system/files. The conf files point to Ghost though, and we need to reverse proxy them to the Commento server.
Update NGINX
We need to edit 3 files: the ssl and *http *conf files for Commento; and the ssl-params file used by NGINX.
We need to reverse proxy NGINX to the Commento server (that we will setup in the next step). In /var/www/ghost/system/files update the commento*.conf files. Their Location / block should look like this
You will need to add this to /var/www/ghost/content/themes/casper/post.hbs. The section is near the bottom, in a commented out block. Uncomment the container and replace the contents with the above snippet.
To get Ghost to compile and use the new template, restart Ghost
# Switch to the commento usersudo-u commento
# Move to Ghost rootcd /var/www/ghost
#Restart
ghost restart
You should be all set. Comments should start showing up in your posts.
Self-Hosting Commento alongside Ghost 2.x
Tim Kye
I recently upgraded this blog to Ghost 2.x and took the opportunity to abandon Disqus. It bloated the post page and came with something like 45 tracking scripts/cookies. To replace it I settled on Commento, a small and privacy-focused open source solution. The minimum subscription is $3/month, which is a bit high for a blog that I only pay $5/month for. Luckily they offer a self-hosted option. Here is how I got it setup.
Since I am running this blog on Digital Ocean I chose to install and run Commento from the same Droplet (Virtual Machine). You don't need to do this, but the smallest Droplet is sufficient to run Ghost and Commento side-by-side if your traffic isn't too high.
Prerequisites
adduser commento
), matched it to a databse role (createuser --interactive
, name it "commento") and a database of the same name (createdb commento
). When you are done make sure yousudo systemctl enable postgresql
to keep it running.commento.blog.kye.dev
, and pointed it to the same floating IP that Ghost is on.Install Commento
Create SSL Cert
This is the same process used to add certs for alternate/redirect domains.
This will create certs with Lets Encrypt/acme.sh, as well as generate some NGINX conf files in
/var/www/ghost/system/files
. The conf files point to Ghost though, and we need to reverse proxy them to the Commento server.Update NGINX
We need to edit 3 files: the ssl and *http *conf files for Commento; and the ssl-params file used by NGINX.
We need to reverse proxy NGINX to the Commento server (that we will setup in the next step). In
/var/www/ghost/system/files
update thecommento*.conf
files. TheirLocation /
block should look like thisThen in
/etc/nginx/snippets/ssl-params.conf
remove/comment out the following line:Create the Commento Service
Create the following file at
/etc/systemd/system/commento.service
Then run
To get NGINX routing to Commento you will need to restart it.
Register Domain in Commento
Commento should be running now. You need to complete the domain setup in the Commento dashboard (the one running on your server, not the cloud one).
Add Commento code to Ghost Template
Once your domain is registered in the dashboard a snippet is provided under the installation section. It looks like this
You will need to add this to
/var/www/ghost/content/themes/casper/post.hbs
. The section is near the bottom, in a commented out block. Uncomment the container and replace the contents with the above snippet.To get Ghost to compile and use the new template, restart Ghost
You should be all set. Comments should start showing up in your posts.