This guide installs Wiki.js as a systemd-managed Node.js service with PostgreSQL.
It supports Debian 10 to latest stable, Ubuntu LTS, and RHEL 9+ compatible systems.
- name: Install Wiki.js
hosts: wikijs
become: true
vars:
wikijs_user: wikijs
wikijs_group: wikijs
wikijs_home: /opt/wikijs
wikijs_port: 3000
tasks:
- name: Install dependencies on Debian/Ubuntu
apt:
name:
- nodejs
- npm
- postgresql
- postgresql-contrib
- curl
- git
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install dependencies on RHEL family
dnf:
name:
- nodejs
- npm
- postgresql-server
- postgresql
- curl
- git
state: present
when: ansible_os_family == "RedHat"
- name: Initialize PostgreSQL on RHEL family
command: postgresql-setup --initdb
args:
creates: /var/lib/pgsql/data/PG_VERSION
when: ansible_os_family == "RedHat"
- name: Enable and start PostgreSQL
service:
name: postgresql
state: started
enabled: true
- name: Create Wiki.js group
group:
name: "{{ wikijs_group }}"
state: present
- name: Create Wiki.js user
user:
name: "{{ wikijs_user }}"
group: "{{ wikijs_group }}"
home: "{{ wikijs_home }}"
shell: /usr/sbin/nologin
create_home: true
- name: Create Wiki.js directory
file:
path: "{{ wikijs_home }}"
state: directory
owner: "{{ wikijs_user }}"
group: "{{ wikijs_group }}"
mode: "0755"
- name: Download Wiki.js release
get_url:
url: https://github.com/requarks/wiki/releases/latest/download/wiki-js.tar.gz
dest: /tmp/wiki-js.tar.gz
mode: "0644"
- name: Extract Wiki.js release
unarchive:
src: /tmp/wiki-js.tar.gz
dest: "{{ wikijs_home }}"
remote_src: true
- name: Install Node.js dependencies
command: npm install --production
args:
chdir: "{{ wikijs_home }}"
- name: Create systemd service
copy:
dest: /etc/systemd/system/wikijs.service
mode: "0644"
content: |
[Unit]
Description=Wiki.js
After=network.target postgresql.service
[Service]
Type=simple
User={{ wikijs_user }}
Group={{ wikijs_group }}
WorkingDirectory={{ wikijs_home }}
Environment=PORT={{ wikijs_port }}
ExecStart=/usr/bin/node server
Restart=on-failure
[Install]
WantedBy=multi-user.target
- name: Reload systemd
systemd:
daemon_reload: true
- name: Enable and start Wiki.js
service:
name: wikijs
state: started
enabled: true
config.yml before first production start.We develop tailored automation solutions for:
Let’s discuss your requirements: office@linux-server-admin.com | Contact