Wiki.js - установка на Ubuntu 22.04

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2024
Перейти к:навигация, поиск

Wiki.js - установка на Ubuntu 22.04

На выходе установки получим:

- Docker
- PostgreSQL 11
- Wiki.js 2.x через 80 порт

Алгоритм установки Wiki.js на Ubuntu 22.04 Jammy (протестировано 21.03.2022):
1) Установить последнюю версию Docker:

# apt update -y
# apt install apt-transport-https ca-certificates curl software-properties-common -y
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# apt update
# apt install docker-ce -y
# systemctl enable docker

2) Настраиваем 3 контейнера: базу Postgresql 11, сам wiki.js, и систему обновления wiki-update-companion:

# mkdir -p /etc/wiki
# openssl rand -base64 32 > /etc/wiki/.db-secret
# docker network create wikinet
# docker volume create pgdata
# docker create --name=db -e POSTGRES_DB=wiki -e POSTGRES_USER=wiki -e POSTGRES_PASSWORD_FILE=/etc/wiki/.db-secret -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro -v pgdata:/var/lib/postgresql/data --restart=unless-stopped -h db --network=wikinet postgres:11
# docker create --name=wiki -e DB_TYPE=postgres -e DB_HOST=db -e DB_PORT=5432 -e DB_PASS_FILE=/etc/wiki/.db-secret -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro -e DB_USER=wiki -e DB_NAME=wiki -e UPGRADE_COMPANION=1 --restart=unless-stopped -h wiki --network=wikinet -p 80:3000 -p 443:3443 ghcr.io/requarks/wiki:2
# docker create --name=wiki-update-companion -v /var/run/docker.sock:/var/run/docker.sock:ro --restart=unless-stopped -h wiki-update-companion --network=wikinet ghcr.io/requarks/wiki-update-companion:latest

где

/etc/wiki/.db-secret - пароль от базы wiki

Проверяем какие контейнеры создались:

# docker ps -a
CONTAINER ID   IMAGE                                           COMMAND                  CREATED         STATUS    PORTS     NAMES
4b54335e88f1   ghcr.io/requarks/wiki-update-companion:latest   "docker-entrypoint.s…"   3 minutes ago   Created             wiki-update-companion
8ab0aca0be2c   ghcr.io/requarks/wiki:2                         "docker-entrypoint.s…"   3 minutes ago   Created             wiki
89ba30b963af   postgres:11                                     "docker-entrypoint.s…"   4 minutes ago   Created             db

Запускаем контейнеры:

# docker start db
# docker start wiki
# docker start wiki-update-companion

3) По-желанию можно настроить UFW фаервол (можно опустить этот пункт):

# ufw allow ssh
# ufw allow http
# ufw allow https
# ufw --force enable

4) Завершаем Wiki.js установку через

http://your_server_ip


Скриншот админки wiki.js:
Wiki-js-screenshot-1.png


Если есть рабочий домен - то нужно сразу создать контейнер wiki c выпуском SSL Let's Ecnrypt и включить редирект в админке wiki.js:

# docker stop wiki
# docker rm wiki
# docker create --name=wiki -e LETSENCRYPT_DOMAIN=103592.ip-ns.net -e [email protected] -e SSL_ACTIVE=1 -e DB_TYPE=postgres -e DB_HOST=db -e DB_PORT=5432 -e DB_PASS_FILE=/etc/wiki/.db-secret -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro -e DB_USER=wiki -e DB_NAME=wiki -e UPGRADE_COMPANION=1 --restart=unless-stopped -h wiki --network=wikinet -p 80:3000 -p 443:3443 ghcr.io/requarks/wiki:2
# docker start wiki

Логи выпуска SSL Lets Encrypt для wiki.js:

# docker logs wiki
Loading configuration from /wiki/config.yml... OK
 DB_PASS_FILE is defined. Will use secret from file.
2023-03-21T21:00:23.726Z [MASTER] info: =======================================
2023-03-21T21:00:23.729Z [MASTER] info: = Wiki.js 2.5.298 =====================
2023-03-21T21:00:23.730Z [MASTER] info: =======================================
2023-03-21T21:00:23.730Z [MASTER] info: Initializing...
2023-03-21T21:00:25.362Z [MASTER] info: Using database driver pg for postgres [ OK ]
2023-03-21T21:00:25.367Z [MASTER] info: Connecting to database...
2023-03-21T21:00:25.437Z [MASTER] info: Database Connection Successful [ OK ]
2023-03-21T21:00:27.060Z [MASTER] warn: Mail is not setup! Please set the configuration in the administration area!
2023-03-21T21:00:27.239Z [MASTER] info: Loading GraphQL Schema...
2023-03-21T21:00:29.643Z [MASTER] info: GraphQL Schema: [ OK ]
2023-03-21T21:00:30.368Z [MASTER] info: HTTP Server on port: [ 3000 ]
2023-03-21T21:00:30.482Z [MASTER] info: (LETSENCRYPT) Initializing Let's Encrypt client...
(node:1) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./public/" in the "exports" field module resolution of the package at  /wiki/node_modules/extract-files/package.json.
Update this package.json to use a subpath pattern like "./public/*".
(Use `node --trace-deprecation ...` to show where the warning was created)
2023-03-21T21:00:30.541Z [MASTER] info: HTTP Server: [ RUNNING ]
2023-03-21T21:00:30.955Z [MASTER] info: (LETSENCRYPT) Setting up account for the first time...
2023-03-21T21:00:32.030Z [MASTER] info: (LETSENCRYPT) Account was setup successfully [ OK ]
2023-03-21T21:00:32.031Z [MASTER] info: (LETSENCRYPT) Generating server keypairs...
2023-03-21T21:00:32.155Z [MASTER] info: (LETSENCRYPT) Server keypairs generated successfully [ OK ]
2023-03-21T21:00:32.155Z [MASTER] info: (LETSENCRYPT) Generating certificate signing request (CSR)...
2023-03-21T21:00:32.161Z [MASTER] info: (LETSENCRYPT) CSR generated successfully [ OK ]
2023-03-21T21:00:32.162Z [MASTER] info: (LETSENCRYPT) Requesting certificate from Let's Encrypt...
2023-03-21T21:00:32.168Z [MASTER] info: (LETSENCRYPT) Setting HTTP challenge for 103592.ip-ns.net: [ READY ]
2023-03-21T21:00:32.168Z [MASTER] info: (LETSENCRYPT) Waiting for challenge to complete...


Редирект можно сделать через админку wiki.js --> System --> SSL:
Wiki-js-screenshot--lets-encrypt-1.png