LoginSignup
24
30

More than 3 years have passed since last update.

個人用のWikiをGrowiを用いて構築

Last updated at Posted at 2018-12-10

GROWI v3.4 から必要なミドルウェアのバージョンが変更になった為、本ページは参考になりません。

構築目的と背景

自分用のまとめを効果的に残す方法を探していました。
テキストやExcelなどではファイルの数が増え、サイズも大きくなり
自分のナレッジを引き出すのが面倒になった経験があります。
ただ、薄い内容や調べればすぐわかる内容をQiita等に公開するのは気が引けます。
そんな時にGrowiを見つけました。

Growiとは

  • Markdownで記事記載が可能
  • ファイルのアップロードをサーバへ簡易的にできる
  • Vim/Emacs/Sublime Text のキーマップをサポート。
  • Elasticsearch を利用した検索が可能
  • などなど

■リンク
https://growi.org/
公式デモサイト

Growiを構築する上で必要なもの

今回構築した場所は社内の仮想マシン内(CentOS7.6)に構築しました。

必要なミドルウェア等のバージョンを確認します。
Growi GitHub

必要なもの Version
node 8.x (DON'T USE 9.x)
npm 6.x
yarn -
MongoDB 3.x
Redis 3.x
Elasticsearch 5.x
Japanese (kuromoji) Analysis plugin -
ICU Analysis Plugin -
git -

構築

必要なものを上からインストールしていきます。
※外部公開しない為、SELinuxは無効にしてあります。

Node.js

curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -

すると以下のメッセージがでます。

## Run `sudo yum install -y nodejs` to install Node.js 8.x LTS Carbon and npm.
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn

なので指示通り以下を実行

yum -y install nodejs
  • gcc-c++ make
yum install gcc-c++ make
  • yarn
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
yum install yarn

MongoDB

vi /etc/yum.repos.d/mongodb.repo

内容は以下です。

[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
yum -y install mongodb-org

Redis

yum -y install epel-release
yum -y install redis

systemctl start redis
systemctl enable redis

java-1.8.0-openjdk

※Elasticsearchを動作させる為にJavaが必要です。

yum -y install java-1.8.0-openjdk

Elasticsearch

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
vi /etc/yum.repos.d/elasticsearch5.repo 

内容は以下です。

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

Japanese (kuromoji) Analysis plugin

/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji

ICU Analysis Plugin

/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu

サーバのメモリが少ない場合
Elasticsearchはデフォルトで2GBのメモリを確保する設定になっています。
もし、AWSの安価なEC2を使うと起動出来ない為、以下の設定が必要となります。

vi /etc/elasticsearch/jvm.options

以下を削除またはコメントアウト

-Xms2g
-Xmx2g

任意のメモを割り当て(例:最大、最小ともに1GB)
※公式手順では256m

-Xms1g
-Xmx1g

git

yum install git

Growi

1.インストールするディレクトリへ移動

cd /usr/local/bin

2.Growiのインストール

git clone https://github.com/weseek/growi.git
cd growi
yarn

3.lsxプラグイン追加

yarn add growi-plugin-lsx

4.環境変数の設定

vi /etc/sysconfig/growi

内容は以下です。

PORT=3000
NODE_ENV=production
MONGO_URI="mongodb://localhost:27017/growi"
REDIS_URL="redis://localhost:6379"
ELASTICSEARCH_URI="http://localhost:9200"
#SECRET_TOKEN=
PASSWORD_SEED="`openssl rand -base64 128 | head -1`"
FILE_UPLOAD=local

5.systemctlコマンドでstart stopできるように設定

vi /etc/systemd/system/growi.service

内容は以下です。

[Unit]
Description=Growi
After=network.target mongod.service

[Service]
WorkingDirectory=/usr/local/bin/growi
EnvironmentFile=/etc/sysconfig/growi
ExecStart=/usr/bin/npm start

[Install]
WantedBy=multi-user.target

systemd の設定の再読み込み実施

systemctl daemon-reload

Firewallの設定

firewall-cmd --add-port=3000/udp --zone=public --permanent
firewall-cmd --add-port=3000/tcp --zone=public --permanent
firewall-cmd --reload

色々起動

systemctl start elasticsearch
systemctl enable elasticsearch

systemctl start mongod
systemctl enable mongod

systemctl start growi
systemctl enable growi

 起動確認

以下へアクセスすると管理者情報の登録画面が表示されます。
http://サーバIPアドレス:3000
1.PNG

任意の情報を登録するとログイン画面が表示され、先ほどのIDとパスワードでログインが可能です。

終わりに

Wikiを構築したことで個人PCに散乱していたメモなどをジャンルごとに整理することができました。
自社環境では外部アクセスはできませんが、社内からはアカウント登録なしでも閲覧自体は可能な為、
案件の振り返りやナレッジの共有に活かすことができればと考えています。

参考リンク

公式手順
AWS 上の CentOS7 に Growi をインストールする
CentOS7.5にGrowiをインストール
CentOS7にGrowi(旧Crowi-Plus)をインストールする方法

24
30
1

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
24
30