(u_u)

ubuntu18.04:growiのインストール

Categories: [blog]
Tags: [ubuntu], [systemd], [nginx], [certbot], [growi], [wiki]

基本的にはUbuntu Server | GROWI Docsを参考にしながらインストールしました。それぞれのソフトウェアのバージョンアップによる変更や、Root権限なしでgrowiを起動できるようにしてみました。

elastic searchのインストール

Install Elasticsearch with Debian Package | Elasticsearch Reference [6.6] | Elasticを参考に。

  1. wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
  2. sudo apt-get install apt-transport-https
  3. echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
  4. sudo apt-get update && sudo apt-get install elasticsearch
  5. sudo systemctl start elasticsearch
  6. sudo systemctl status elasticsearch
  7. sudo systemctl enable elasticsearch
growiに必要なElasticserchプラグインのインストール
  1. dpkg -L elasticsearch | grep bin | grep plugin
  2. sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji
  3. sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu
mongodbのインストール

Install MongoDB Community Edition on Ubuntu — MongoDB Manualを参考に。

  1. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
  2. echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
  3. sudo apt-get update
  4. sudo apt-get install -y mongodb-org
  5. sudo systemctl start mongod
  6. sudo systemctl status mongod
  7. sudo systemctl enable mongod
yarnのインストール

参考:Installation | Yarn

  1. https://dl.yarnpkg.com/debian/pubkey.gpg
  2. echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
  3. sudo apt-get update && sudo apt-get install yarn
growi用ユーザーアカウントを作成
  1. sudo adduser growi
growiのインストール
  1. su growi
  2. cd
  3. git clone https://github.com/weseek/growi
  4. cd growi
  5. sudo git tag -l
  6. sudo git checkout -b (RCがついてない最新版) refs/tags/(RCがついてない最新版)
  7. yarn
nginxの設定
server {
    listen 443 ssl;
    server_name wiki.takanotume24.com;

    location / { 
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_read_timeout 900s;
    }   

    ssl_certificate /path/to/fullchain.pem; # managed by Certbot
    ssl_certificate_key /path/to/privkey.pem; # managed by Certbot
}

server {
    if ($host = wiki.takanotume24.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    server_name wiki.takanotume24.com;
    return 404; # managed by Certbot

}
systemdの設定

/etc/systemd/system/growi.service

[Unit]
Description=Growi wiki system
After=network.target

[Service]
Type=simple
User=growi
ExecStart=/bin/bash /home/growi/start.sh
Restart=on-abort
WorkingDirectory=/home/growi
TimeoutSec=300

[Install]
WantedBy=multi-user.target
起動用シェルスクリプト

/home/growi/start.sh

#!/bin/sh
MONGO_URI=mongodb://localhost:27017/growi \
ELASTICSEARCH_URI=http://localhost:9200/growi \
npm start 
growiの起動
  1. sudo systemctl start growi
growiのBootと同時に起動設定
  1. sudo systemctl enable growi