Installing Wiki.js on Ubuntu 20.04, with Postgresql

This probably won’t make sense to anyone else, but these are my notes related to installing Wiki.js and Postgresql on an Ubuntu 20.04 system. Everything here is related to setting up a new Ubuntu system and then running Wiki.js:

New Linode Server (Ubuntu 20)
sudo adduser fred
sudo usermod -aG sudo fred

## Install Postgres

- change the 'postgres' user account password:
    passwd postgres (then supply the password)

- Change the password for the postgres PostgreSQL user to use when connecting over a network.
    psql -c "ALTER USER postgres WITH PASSWORD 'the_password'"

- /etc/postgresql/12/main/pg_hba.conf

## Install Node.js
    apt install nodejs
    nodejs -v

## Connect Postgres & Wiki.js
- become root
- become postgres user:
    sudo -i -u postgres
- create a new user:
    createuser --interactive
    # does not let you set the password here
    # this might work:
    psql -c "ALTER USER db_user WITH PASSWORD 'the_password'"
- create the database
    createdb wiki_js

  # PostgreSQL / MySQL / MariaDB / MS SQL Server only:
  host: localhost
  port: 5432
  user: bd_user
  pass: db_password
  db:   db_name
  ssl:  false

PostgreSQL Backup
pg_dump -h localhost -U db_user -W db_name > db.dump

How to use a Different SSH Port on the Server
vi /etc/ssh/sshd_config
systemctl restart ssh
netstat -tlpn| grep ssh
ss -tlpn| grep ssh

ufw allow 5150/tcp
ufw status verbose


## htpasswd with NGINX
    apt-get install apache2-utils
    # use any directory, as desired:
    touch /etc/nginx/.htpasswd
    htpasswd -c /etc/nginx/.htpasswd the_username

## Wiki.js Setup
- the wiki is now available at
- wiki admin email: foo
- wiki admin pass:  bar

wiki.js version
nodejs -v
psql -version
    psql (12.7 (Ubuntu 12.7-0ubuntu0.20.04.1))

OS: Ubuntu 20.04
Wiki.js version: 2.5.201
Database engine: PostgreSQL 12+214

/etc/systemd/system/wiki.service (how to create a simple Ubuntu service)

# Wiki.js runs with the 'node server' command
ExecStart=/usr/bin/node server
# Consider creating a dedicated user for Wiki.js here:


Reload systemd:
    systemctl daemon-reload

Run the service:
    systemctl start wiki

Enable the service on system boot.
    systemctl enable wiki

Note: You can see the logs of the service using journalctl -u wiki

Again, all of those commands are related to setting up a new Ubuntu system and then running Wiki.js on that server. They recommend using Postgres, and I used to love using Postgres, so I went with it.