Here's some quick and dirty notes on setting up GoatCounter on Nearly Free Speech dot net. There are some rather opaque hoops you need to jump through in order to setup the service. I make no claim that this tutorial is perfect, but hopefully it helps someone else who is frantically searching for a solution.

Create a new site

  1. No need for a custom domain, we're going to use the provided sub-domain.
  2. Select 'custom server'
  3. Mark it as a production service

Installing GoatCounter

SSH Into your new website. Your username will be in your 'SSH/SFTP Information' section of your site. At this point I just compiled goatcounter from source. It was easier than trying to figure out if the provided architectures would work with

git clone -b release-1.4
cd goatcounter
go build -ldflags="-X main.version=$(git log -n1 --format='%h_%cI')" ./cmd/goatcounter

Create a login account for GoatCounter. The domain in this case is the domain that you will access GoatCounter on, it is not the domain of the site you want to monitor.

/goatcounter/goatcounter create -email -domain

Setting up the run script

Now we need to set a bunch of permissions so the web daemon can read the files we just created.

chgrp web acme-secrets
chmod g+r acme-secrets
chgrp web db
chmod 760 db
chgrp web db/goatcounter.sqlite3
chmod 760 db/goatcounter.sqlite3

(I'm not a 100% certain on these permissions, but if you run into trouble you can check the server logs in /home/logs/. Look for an error message indicating GoatCounter can't read a particular file. Now we create a run script for NFS so they can restart the service if it ever goes down.

In /home/protected/ write:

/home/public/goatcounter/goatcounter serve -listen :8081 -port 8081 -tls none

Give it the execute permission for good measure.

chmod +x /home/protected/

Setup HTTP port forwarding for the site through the NFS portal. Add the daemon with default settings Visit your site's nfs-host sub-domain to see if it's working. Go ahead and log in.

Finally copy the javascript tracker into your site. You'll need to modify the URL to remove the port since that isn't publicly accessible.

Good luck.