LoginSignup
2
3

More than 5 years have passed since last update.

Raspberry Pi3でGrowiを動かす

Last updated at Posted at 2018-09-16

概要

「Raspberry Pi3にFedora28を入れる」の続きです。
Raspberry Pi3B+を使用しました。

Fedora28を入れたRaspberry Pi3で、Markdown形式で記載できるWiKiであるGrowiを入れて、動作するところまでのメモです。手順は「Ubuntu18.04にGrowiをインストール」とほぼ同じです。

セットアップ

Java8

まず、java8が必要なので、入っているか確認。

$ java --version
Command 'java' not found, but can be installed with:

入っていないといわれる場合はインストールする。

$ sudo dnf -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
$ java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b15)
OpenJDK 64-Bit Server VM (build 25.181-b15, mixed mode)

インストール先を確認し、JAVA_HOMEを設定する。

$ dirname $(readlink $(readlink $(which java)))
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181.b15-0.fc28.aarch64/jre/bin

$ sudo vi /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181.b15-0.fc28.aarch64
export PATH=$PATH:$JAVA_HOME/bin

$ source /etc/profile
$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181.b15-0.fc28.aarch64

Elasticsearch 

手順は公式ドキュメントに従います。
リポジトリキーの設定後、dnfでインストール可能です。

$ sudo rpm --import https://packages.elasticsearch.org/GPG-KEY-elasticsearch
$ sudo vi /etc/yum.repos.d/elasticsearch.repo  (新規作成)

[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

$ sudo dnf -y install elasticsearch

日本語プラグインを追加する。

$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji
$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu

メモリ使用量を変更する。
デフォルトだと2GBになっているが、ラズパイはそもそも1GBしか積んでないためエラーで起動しない。
Growiの公式ドキュメントで、個人使用であれば256MBで十分という記載がある。

$ sudo vi /etc/elasticsearch/jvm.options
    -Xms256m
    -Xmx256m

このまま起動すると、X-Pack is not supported and Machine Learning is not available for [linux-aarch64]のエラーが出るため、(影響はわからないけど)X-Packを無効にする。
設定ファイルの末尾に下記1行を追加する。

$ sudo vi /etc/elasticsearch/elasticsearch.yml
xpack.ml.enabled: false

起動

$ sudo systemctl start elasticsearch

数分待ってからステータスを確認。

$ sudo systemctl status elasticsearch
$ curl localhost:9200
{
  "name" : "WYyHqAI",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "Lwf4xUVtSBOPepknI8yqKQ",
  "version" : {
    "number" : "6.4.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "595516e",
    "build_date" : "2018-08-17T23:18:47.308994Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

問題なければ自動起動を設定する

$ sudo systemctl enable elasticsearch

Redis

インストールから自動実行まで。

$ sudo dnf -y install redis
$ sudo systemctl start redis
$ sudo systemctl status redis
$ sudo systemctl enable redis

Growi

公式手順に従います。

$ cd /opt
$ sudo git clone https://github.com/weseek/growi
$ cd growi
$ sudo git tag -l
$ sudo git checkout -b v3.2.1 refs/tags/v3.2.1
$ sudo yarn

1時間くらいかかる。
以下のようにして、起動確認を行う。

$ sudo \
NODE_ENV=production \
MONGO_URI=mongodb://localhost:27017/growi \
ELASTICSEARCH_URI=http://localhost:9200/growi \
REDIS_URI=redis://localhost:6379 \
PASSWORD_SEED=xxxx (MAX64文字のランダム文字列) \
FILE_UPLOAD=local \
npm start

とりあえず20分くらい待ちましょうか・・・
[production] Express server listening on port 3000の表示が出たら起動OK。
ブラウザで、http://serverIP:3000/ を表示し、初期ページが出ることを確認する。


初期ページが表示されないとき

デフォルトのままだとSELinuxが有効になっているので無効化する。

$ sudo getenforce
Enforcing (有効)

$ sudo vi /etc/sysconfig/selinux
SELINUX=disables # disabled に変更

Firewallを確認し有効な場合、無効化する。

$ sudo systemctl status firewalld
$ systemctl stop firewalld 
$ systemctl disable firewalld rolekit

※rolekitはserver管理ツールで、firewallを起動してしまうので、一緒に止めておく。

再起動し、確認。

$ sudo getenforce
Permissive
$ sudo systemctl status firewalld

自動起動の設定

$ sudo vi /etc/systemd/system/growi.service

[Unit]
Description = growi
After=network-online.target mongod.service
ConditionPathExists=/opt/growi

[Service]
ExecStart=/opt/growi/growi-start.sh
Restart=no
Type=simple

[Install]
WantedBy=multi-user.target

Description : 説明文、何を書いてもよい
After : 起動順の指定。networkとmongodの起動後にスタートするよう設定
ConditionPathExists : インストールディレクトリ
ExecStart : 起動スクリプト
他は特に触る必要はない。

作成したファイルの権限を変更する。

$ sudo chown root:root /etc/systemd/system/growi.service
$ sudo chmod 644 /etc/systemd/system/growi.service

起動スクリプトを作成する。
growi.serviceのExecStartに設定したパスに作る。
サービスはroot権限で実行されるのでsudoは不要。

$ sudo vi /opt/growi/growi-start.sh

#!/bin/sh

cd /opt/growi
NODE_ENV=production \
MONGO_URI=mongodb://localhost:27017/growi \
ELASTICSEARCH_URI=http://localhost:9200/growi \
REDIS_URI=redis://localhost:6379 \
PASSWORD_SEED=xxxx (MAX64文字のランダム文字列) \
FILE_UPLOAD=local \
npm start

実行権限を付与する。

$ sudo chmod +x /opt/growi/growi-start.sh

デーモンを再起動しGrowiサービスの起動・確認

$ sudo systemctl daemon-reload
$ sudo systemctl start growi.service
$ sudo systemctl status growi.service

statusでログ見えるが、全部見れない場合はsudo journalctl -u growi -bで見れる。
セットアップは終わってるので5分くらいで立ち上がるかと思います。

問題なければ自動起動を設定する。

$ sudo systemctl enable growi.service

メモ

なんとなく反応遅いが、動いてる。
ファイルアップロードも若干時間かかるが、問題なし。
全文検索はだめかもしれない。(これ以上は調べません^^;)

参考

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3