LoginSignup
0
1

More than 5 years have passed since last update.

CentOSにSCLを利用して Growi をインストールする

Last updated at Posted at 2019-03-08

はじめに

CentOS + Growiという組み合わせについては,世の中に良記事がたくさん見つかるので,それで十分ならば,そちらを読んだ方が丁寧です.私は以下の記事を参考にしました.良い記事を本当にありがとう.

何が違うの?

各ソフトウェアの公式版や最新版を使いたいならば,上記記事を見たほうが良いです.本当にわかりやすかったです.
が,私はなるべくディストリビューションに近いレベルの方法でやっていきたい.ということで,SCLを使った方法を試してみた.ここでは,その差分を中心に簡単なまとめておこうと思う.

この記事で説明しないこと

手順

1. CentOS/Redhat Software Collection (SCL) を入れる

$ sudo yum install centos-release-scl{,-rh}

私は yumコマンドを使うたびに scl を常に参照するのが気になるので,yum-config-managerで無効化している.yum-config-manageryum-utilsに入っている.

$ sudo yum install yum-utils
$ sudo yum-config-manager --disable centos-sclo-{sclo,rh} > /dev/null

リポジトリを無効化した場合,yumコマンドを使うたびにyum --enablerepo=centos-sclo-rhとする必要があるので,手間と言えば手間だが,メンテナンスを思うと,こちらの方がいいと思っている.

2. gitのインストール(オプション)

最新版(になるべく近い版)が使いたいときもある(よね?).下記コマンドのgitのバージョン番号はその時々のSCLのリポジトリをみて書き換える必要がある.ここでは,2.18を入れている.

$ sudo yum --enablerepo=centos-sclo-rh install rh-git218

3. mongodbのインストール

バージョン番号への注意はgitをインストールするときと同じ.

$ sudo yum --enablerepo=centos-sclo-rh install rh-mongodb36

なお,systemdのサービスとしては,以下のファイルで定義される.

/usr/lib/systemd/system/rh-mongodb36-mongod.service

従って,このmongodbのmongodをサービスとして起動するのであれば,以下のコマンドとなる.

$ sudo systemctl start rh-mongodb36-mongod

4. Node.jsとyarnのインストール

$ sudo yum --enablerepo=centos-sclo-rh install rh-nodejs10
$ sudo scl enable rh-nodejs10 'npm install -g yarn'

2行目を補足すると,sclコマンドで環境変数を加えつつ,npmでglobalにyarnをインストール.(説明できていないような気もするが,雰囲気を感じ取っていただきたく...)なお,インストール後のメッセージにも出てくるが,この方法だと yarn/opt/rh/rh-nodejs10/root/usr/bin/yarn に設置される.

なお,scl enableでコマンドを打つのはメンドクサイと言う人は,このあたりで,以下のコマンドを打っておくのもよろしいかと思われ.

$ scl enable rh-git218 rh-mongodb36 rh-nodejs10 bash

最後の実行コマンド部分をbashにすることで,各環境変数を設定したbashが立ち上がる.

5. Growi のインストール

個人的な趣味により,/opt/growi に入れようと思う.

1行目のinstallコマンドはmkdirしつつ,chownしているだけである.-ovagrant-gvagrantはそれぞれの環境でのユーザとグループに置き換えてほしい.
git cloneの最後のドット(カレントディレクトリ)も忘れずに.

$ scl enable rh-git218 bash
$ sudo install -ovagrant -gvagrant -d /opt/growi
$ cd /opt/growi
$ git clone --depth=1 https://github.com/weseek/growi.git .

6. systemdのサービスとして登録する

前述の@yuki476氏のQiita記事から利用させてもらう.

  • /etc/sysconfig/growi はそのまま作ればよい
  • /etc/systemd/system/growi.service はSCLのための手当てが必要.以下のような書き方になる.
[Unit]
Description=Growi
After=network.target rh-mongodb36-mongod.service

[Service]
WorkingDirectory=/opt/growi
EnvironmentFile=/etc/sysconfig/growi
ExecStart=/usr/bin/scl enable rh-git218 rh-mongodb36 rh-nodejs10 'npm start'

[Install]
WantedBy=Multi-user.target

ちなみに,growi.serviceファイルは,書き換えるたびに以下のコマンドでリロードする必要がある.

$ systemctl daemon-reload

7. 終了(サービス起動)

$ systemctl start rh-mongodb36-mongod growi
0
1
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
0
1